kettek2/wiki/playground/spin/index.js

14 lines
432 B
JavaScript

(function() {
let els = document.getElementsByClassName('spin-transition');
function updateSpin(el, val) {
el.className = 'spin-transition spin-'+(val);
}
window.setInterval(() => {
let date = Math.round((new Date().getTime()+200) / 1000); // +200ms for anim
let seconds = (date+"").charAt((date+"").length-1);
for(let i = 0; i < els.length; i++) {
updateSpin(els[i], seconds);
}
}, 1000);
})();