问题
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://jsfiddle.net/rdzo13cf/6/
In the example above the last item in the data is not displayed.
回答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
来源:https://stackoverflow.com/questions/32997633/stop-iteration-when-end-of-data-objects-are-reached