Example #9: generating password with fake progress
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,e.g. ,
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.
Other examples with callbacks
Other examples with chain interruption
Other examples with closed loops
- Example #4: blinking a given number of times on click
- Example #5: create dynamic tables with instant loops
- Example #8: simple progress indicator with text
- Example #11: change the banner randomly in an interval loop
- Example #12: cyclic button clicks
- Example #15: enable continue button only after making choices
- Example #18: falling little boxes
- Example #20: ruler with animation
Other examples with inline attached events
- Example #3: a simple inline click handler
- Example #4: blinking a given number of times on click
- Example #10: fading submenus with user friendly timeouts
- Example #12: cyclic button clicks
- Example #13: quick image selection
- Example #14: wait a timeout after each click before blinking
- Example #18: falling little boxes
Other examples with intervals
Other examples with repeat-loops
- Example #1: repeated blinking (like in the old days with the deprecated
<blink>
element) - Example #2: repeated blinking with iterated timeouts
- Example #4: blinking a given number of times on click
- Example #5: create dynamic tables with instant loops
- Example #6: iterate all selected elements with a timeout
- Example #7: clock display with one short blink per second
- Example #8: simple progress indicator with text
- Example #11: change the banner randomly in an interval loop
- Example #12: cyclic button clicks
- Example #14: wait a timeout after each click before blinking
- Example #16: playing pong with divs
- Example #17: scheduling different elements' animations
- Example #18: falling little boxes
- Example #20: ruler with animation