Last active
November 5, 2016 23:11
-
-
Save shamdasani/ba381da14bf2fc64fc0c91993a560c21 to your computer and use it in GitHub Desktop.
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
function moveHands() { | |
with(new Date()) { | |
h = 30 * (getHours() % 12 + getMinutes() / 60); // 30 degrees hour | |
m = 6 * getMinutes(); // 6 degrees every minute | |
s = 6 * getSeconds(); // 6 degrees every second | |
document.getElementById('seconds').style.cssText = "-webkit-transform:rotate(" + s + "deg);"; // setting the rotate CSS attribute to those degree values | |
document.getElementById('minutes').style.cssText = "-webkit-transform:rotate(" + m + "deg);"; | |
document.getElementById('hours').style.cssText = "-webkit-transform:rotate(" + h + "deg);"; | |
setTimeout(moveHands, 1000); // calling the function every second | |
} | |
} | |
window.onload = moveHands; // making sure the function starts on load of webpage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment