Created
August 9, 2017 15:44
-
-
Save charrismatic/84555db046187b7c50a34b3e28966cbf to your computer and use it in GitHub Desktop.
Cycle things with javascript
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
<i>1</i> | |
<i>2</i> | |
<i>3</i> | |
<i>4</i> | |
<i>5</i> | |
<i>6</i> |
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
http://jsfiddle.net/tthd93c3/ | |
function set(n){ | |
for ( i of n ){ | |
i.style.transition="300ms ease-in 40ms"; | |
i.style.opacity="0"; | |
} | |
} | |
function cycle(n){ | |
n.push(n[0]); | |
n[0].style.opacity="1"; | |
window.setTimeout(function(){ | |
n[0].style.opacity="0"; | |
n.shift(); | |
cycle(n); | |
},1500); | |
} | |
var n = Array.prototype.slice.call(document.querySelectorAll('i')); | |
set(n); | |
cycle(n); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment