-
Notifications
You must be signed in to change notification settings - Fork 10
Stop animation after one cycle #1
Comments
Ok, I managed to get something working. There's probably a better way to do this, but I added an extra IF to detect when there's been a full cycle, at which point the recursion stops and data gets cleared and restored.
The desired effect works when I use this config:
The only issue, and this is an issue in general, is if you fire off the Rainbow function on something that's currently animating, it starts to animate the generated markup, and things get crazy! So i'm not the most experienced JS/jQuery guy, and I dont really understand the convention you're using, with the open parenthesis after "if (options.animate) {", the initial unnamed function "function(obj,interval) {", and the following "(obj,pause?options.pauseLength:options.animateInterval);". Do you know what this pattern is called, so I can read more about it? Thanks! |
The parenthesis around the function is creating a "closure" which is used to keep the object being rainbow-ified in scope for the setTimeout function. The pause?options.pauseLength:options.animateInterval is called a ternary, basically it says if (pause) { options.pauseLength } else { options.animateInterval } |
thanks for this. |
Hi,
This is a great script, and nice and clean. I've been messing with the code, trying to get an animation that just runs once, stops, and then resets the text to its pre-processed state, but haven't been totally successful. Got any tips?
Thanks,
Brian
The text was updated successfully, but these errors were encountered: