Skip to content

Instantly share code, notes, and snippets.

@charrismatic
Created August 9, 2017 15:44
Show Gist options
  • Save charrismatic/84555db046187b7c50a34b3e28966cbf to your computer and use it in GitHub Desktop.
Save charrismatic/84555db046187b7c50a34b3e28966cbf to your computer and use it in GitHub Desktop.
Cycle things with javascript
<i>1</i>
<i>2</i>
<i>3</i>
<i>4</i>
<i>5</i>
<i>6</i>
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