Skip to content Skip to sidebar Skip to footer

Stop Iteration When End Of Data Objects Are Reached

Using the TweenMax library, I am unable to kill or stop a delayedCall when the end of the data object is reached instead of looping because it is a self calling function. https://j

Solution 1:

Actually it's because you are incrementing your iter variable before you set it. Which causes it to not display the last item, you want to increment after:

function setContent() {
    element.html(data[iter].content);
    iter = iter >= data.length-1 ? -1 : iter;
    iter = iter + 1;    
}

Basically you are going over indexes [1,2,3] when you want to be going over [0,1,2].

Fiddle Example

Post a Comment for "Stop Iteration When End Of Data Objects Are Reached"