- - no parameters -
If multiple elements are used in a .repeat() context and only a subset does .unrepeat() then the invocation chain can still go on with the remaining elements.
Examples with breaking loop repetition
Of course generating a random password is done in less than a millisecond. But you want to simulate heavy computational things going on – just for a nice user experience.Given that you have a method which adds one random character at a time to an input value,
then you can use that to build our password generator.
So what happens here?
- First we interrupt any possibly ongoing password generation by using .unrepeat().
- We clear the current password value and add a nice animated gif in the background with .val('').addClass('load').
- Now we repeatedly add a new random character with .repeat(200).val(addRandomChar).
- After doing so for 10 times we stop and then remove our CSS class with .until(10).removeClass('load').
Try out clicking multiple times on that button. You will see, that the ongoing animation is always stopped before starting over.
This example shows how to create a ruler with an animated selection mark.
Each time the user clicks on one of the tick marks the button moves up to this mark. During its animation all underlying ticks get highlighted when the button flies by.
This is the complete code:⇒