Last active
August 29, 2015 14:10
-
-
Save drifterz28/5f6f6e967e330b7a4fe1 to your computer and use it in GitHub Desktop.
animated clock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="clock"> | |
<div class="min_hand"></div> | |
<div class="center"></div> | |
<div class="hour_hand"></div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fire animation when the fire class is added | |
var clock = document.querySelector('.clock'); | |
clock.addEventListener('click', function(e) { | |
e.currentTarget.classList.toggle('fire'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$stroke: 10px; | |
$hand-stroke: 6px; | |
$clock-color: black; | |
.clock { | |
border-radius: 50%; | |
height: 200px; | |
width: 200px; | |
border: $stroke solid $clock-color; | |
position: relative; | |
.center { | |
width: #{$hand-stroke}; | |
height: #{$hand-stroke}; | |
background: $clock-color; | |
border-radius: 50%; | |
margin: 0 auto; | |
position: absolute; | |
top: calc(50% - (#{$hand-stroke} / 2)); | |
left: calc(50% - (#{$hand-stroke} / 2)); | |
} | |
.min_hand, | |
.hour_hand { | |
background: $clock-color; | |
position: absolute; | |
height: 48%; | |
left: calc(50% - 3px); | |
top: calc(50% - 48%); | |
border-radius: 50% 50% 0 0; | |
width: $hand-stroke; | |
transform-origin: center bottom; | |
-webkit-transform: rotate(0); | |
transform: rotate(0); | |
} | |
.hour_hand { | |
height: 30%; | |
top: calc(50% - 30%); | |
} | |
} | |
.fire { | |
.hour_hand { | |
-webkit-animation: hand 30s infinite linear; | |
animation: hand 30s infinite linear; | |
} | |
.min_hand { | |
-webkit-animation: hand 5s infinite linear; | |
animation: hand 5s infinite linear; | |
} | |
} | |
@-webkit-keyframes hand { | |
0% { | |
-webkit-transform: rotate(0); | |
} | |
100% { | |
-webkit-transform: rotate(360deg); | |
} | |
} | |
@keyframes hand { | |
0% { | |
transform: rotate(0); | |
} | |
100% { | |
transform: rotate(360deg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment