Skip to content

Instantly share code, notes, and snippets.

@drifterz28
Last active August 29, 2015 14:10
Show Gist options
  • Save drifterz28/5f6f6e967e330b7a4fe1 to your computer and use it in GitHub Desktop.
Save drifterz28/5f6f6e967e330b7a4fe1 to your computer and use it in GitHub Desktop.
animated clock
<div class="clock">
<div class="min_hand"></div>
<div class="center"></div>
<div class="hour_hand"></div>
</div>
// fire animation when the fire class is added
var clock = document.querySelector('.clock');
clock.addEventListener('click', function(e) {
e.currentTarget.classList.toggle('fire');
});
$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