Last active
June 22, 2016 18:53
-
-
Save themartorana/d15e527df5cbd8784605a8c11ca2ed26 to your computer and use it in GitHub Desktop.
Make the Archilovers clock on the Inspiration tab sweeping seconds.
This file contains 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
// Here You can type your custom JavaScript...// Clock | |
function clock() { | |
var clockSeconds = document.getElementById('clock-seconds'), | |
clockMinutes = document.getElementById('clock-minutes'), | |
clockHours = document.getElementById('clock-hours'); | |
function getTime() { | |
requestAnimationFrame(getTime); | |
var date = new Date(), | |
seconds = date.getSeconds(), | |
minutes = date.getMinutes(), | |
hours = date.getHours(), | |
milliseconds = date.getMilliseconds(); | |
var degSeconds = seconds * 360 / 60 + milliseconds * 360 / 60000, | |
degMinutes = (minutes + seconds / 60) * 360 / 60, | |
degHours = (hours + minutes / 60 + seconds / 60 / 60) * 360 / 12; | |
clockSeconds.setAttribute('style', '-webkit-transform: rotate(' + degSeconds + 'deg); -moz-transform: rotate(' + degSeconds + 'deg); -ms-transform: rotate(' + degSeconds + 'deg); -o-transform: rotate(' + degSeconds + 'deg); transform: rotate(' + degSeconds + 'deg);'); | |
clockMinutes.setAttribute('style', '-webkit-transform: rotate(' + degMinutes + 'deg); -moz-transform: rotate(' + degMinutes + 'deg); -ms-transform: rotate(' + degMinutes + 'deg); -o-transform: rotate(' + degMinutes + 'deg); transform: rotate(' + degMinutes + 'deg);'); | |
clockHours.setAttribute('style', '-webkit-transform: rotate(' + degHours + 'deg); -moz-transform: rotate(' + degHours + 'deg); -ms-transform: rotate(' + degHours + 'deg); -o-transform: rotate(' + degHours + 'deg); transform: rotate(' + degHours + 'deg);'); | |
} | |
getTime(); | |
} | |
clock(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment