Last active
July 28, 2016 15:00
-
-
Save diegolameira/4d622c9e7bb53382a9e8 to your computer and use it in GitHub Desktop.
Just a reference to go back and forth into an array with loop. See it in action: http://run.plnkr.co/plunks/7ngbHx/
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
var step = 1, | |
active = 0, | |
items = new Array(); | |
function next(){ | |
active = (active + step) % items.length; | |
// active = ++active % items.length; | |
} | |
function prev(){ | |
active = (active - step) % items.length; | |
if ( active < 0 ) active = items.length - Math.abs(active); | |
// simple for 1 step | |
// active = active ? --active : items.length - Math.abs(--active); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment