css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

<div class="clock">
<div class="dial-container dial-container--hh js-clock" data-cur="9" data-start="0" data-end="12" data-dur="hh"></div> &nbsp;
<div class="dial-container dial-container--mm js-clock" data-cur="2" data-start="0" data-end="5" data-dur="mm"></div><div class="dial-container dial-container--m js-clock" data-cur="3" data-start="0" data-end="9" data-dur="m"></div>  
<div class="dial-container dial-container--ss js-clock" data-cur="4" data-start="0" data-end="5" data-dur="ss"></div><div class="dial-container dial-container--s js-clock" data-cur="8" data-start="0" data-end="9" data-dur="s"></div>
              $dial-x = 65px
$dial-y = 50px
$dial-bg = #462c2e
$dial-color = #fff
$dial-font-x = 55px

body, html
  height: 100%
  width: 100%
  margin: 0
  padding: 0
  background: #f65041
  font-family: Lato, arial
  box-sizing: border-box
.transitions-off *
  transition: none !important

  position: absolute
  top: 150px
  left: 0
  right: 0
  margin: 0
  display: block
  text-align: center

  display: inline-block
  position: relative
  text-align: center
  margin: auto
  perspective: 1000
  height: $dial-y * 2
  width: $dial-x
  cursor: default
    width: $dial-font-x + $dial-x
  width: $dial-x
  height: $dial-y
  top: 0
  height: ($dial-y / 2)
  /* overflow: hidden */ 
  transition: all 0.6s
  transform-style: preserve-3d
  position: absolute
  z-index: 3
  transform-origin: 50px $dial-y

  display: block
  backface-visibility: hidden
  position: absolute
  top: 0
  left: 0
  height: $dial-y
  overflow: hidden
  background: $dial-bg
  color: $dial-color
  text-align: center
  line-height: ($dial-y * 2)
  font-size: 80px
  font-weight: bold
  border-radius: 10px 10px 0 0
  .dial-container--ss &,
  .dial-container--mm &
    text-align: right
    padding-right: 2px
    border-radius: 10px 0 0 0
  .dial-container--hh &
    text-align: center
    min-width: ($dial-x + $dial-font-x)
  .dial-container--s &,
  .dial-container--m &
    text-align: left
    padding-left: 2px
    border-radius: 0 10px 0 0

  z-index: 2
  transform: rotateY(0deg)
  background-color: darken($dial-bg, 15%)
  color: darken($dial-color, 20%)
    display: block
    width: 100%
    height: 1px
    background: rgba(0,0,0,0.2)
    content: ' '
    position: absolute
    bottom: 0
    left: 0

  transform: rotateY(180deg)
  border-radius:  0 0 10px 10px
  line-height: 0
  transform rotateX(180deg)
  .dial-container--ss &,
  .dial-container--mm &
    border-radius: 0 0 0 10px
  .dial-container--s &,
  .dial-container--m &
    border-radius: 0 0 10px 0
.dial--static, .dial--next
  transform: rotateX(0deg) !important

  z-index: 2
  transform: rotateX(180deg) !important

  z-index: 2

  z-index: 1

              nthDigit = (int, nth) ->

setAttributes = ->
  timeNow = new Date()
  # Set hours
  hours   = timeNow.getHours()
  if hours > 12 then hours -= 12
  $('.js-clock[data-dur="hh"]').attr('data-cur', (hours + 1))
  minutes = timeNow.getMinutes()
  if minutes < 10
    $('.js-clock[data-dur="mm"]').attr('data-cur', 1)
    $('.js-clock[data-dur="m"]').attr('data-cur', (minutes + 1))
    $('.js-clock[data-dur="mm"]').attr('data-cur', (nthDigit(minutes, 0) + 1))
    $('.js-clock[data-dur="m"]').attr('data-cur', (nthDigit(minutes, 1) + 1))
  seconds = timeNow.getSeconds()
  minutes = timeNow.getMinutes()
  if seconds < 10
    $('.js-clock[data-dur="ss"]').attr('data-cur', (1))
    $('.js-clock[data-dur="s"]').attr('data-cur', (seconds + 1))
    $('.js-clock[data-dur="ss"]').attr('data-cur', (nthDigit(seconds, 0) + 1))
    $('.js-clock[data-dur="s"]').attr('data-cur', (nthDigit(seconds, 1) + 1))

tick = ($el) ->
  $active = $el.find('.dial--active')
  if $active.next().hasClass 'dial--last'
    setTimeout ( -> 
    	reset($el)), 300, $el

enableTransitions = ($el) ->
reset = ($el) ->
  $el.addClass 'transitions-off'
  $el.children().removeClass 'dial--flipped'
  $el.children().removeClass 'dial--active'
  $el.children().removeClass 'dial--next'
  $el.children().first().addClass 'dial--active'
  $el.children(':nth-child(2)').addClass 'dial--next'
  $el.children(':nth-child(n+3)').addClass 'dial--later'
  setTimeout ( ->
  	enableTransitions($el)), 300, $el
  if $el.attr('data-dur') is 's'
  if $el.attr('data-dur') is 'ss'
  if $el.attr('data-dur') is 'm'
  if $el.attr('data-dur') is 'mm'

setClasses = ($el) ->
  curIndex = parseInt $el.attr('data-cur')
  $el.children(':nth-child(' + curIndex + ')').addClass('dial--active')
  $el.children(':nth-child(' + (curIndex + 1) + ')').addClass('dial--next')
  $el.children(':lt(' + curIndex + ')').addClass('dial--flipped')
  $el.children(':gt(' + (curIndex) + ')').addClass('dial--later')

startClock = ->
  setInterval( ->
  , 1000)
appendEls = ->  
  $('.js-clock').each ->
    $el = $(this)
    start = parseInt $(this).attr('data-start')
    end = parseInt $(this).attr('data-end')
    k = start
    while k <= end
      if (k + 1) > end then l = 0 else l = (k + 1)
      $el.append('<div class="dial"><span>' + k + '</span><span>' + l + '</span>')
    $el.prepend('<div class="dial"><span>0</span><span>0</span></div>')
    $el.append('<div class="dial dial--last"><span>0</span><span>0</span></div>')
attachEvents = ->  
  $('.js-clock').on 'click', (e) ->
    $el = $(this)
    $active = $el.find('.dial--active')
  $(document).on '10s', ->
  $(document).on '60s', ->
  $(document).on '10m', ->
   $(document).on '60m', ->
$(document).ready ->
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................