Total time (ms) for the entire string to unscramble. Every char will take: (unscrambleSpeed/text.length)
Time interval (ms) for the random characters to regenerate and display.
If the value entered is greater than the time it takes for every char to unscramble, the new value will be calculated as: (unscrambleSpeed/text.length/1.01). This will guarantee that the animation executes.
var charResolveSpeed = unscrambleSpeed/text.length;
if(charResolveSpeed <= randomizerSpeed) {
randomizerSpeed = charResolveSpeed/1.01;
}
.innerHTML.There is an element class modifier to inhibit element-unique re-triggers. Multiple mouseenters will not create adverse effects. May consider making this an optional flag.
Must fix the bold replacement issue. Workaround: Add class modifier as found in bootstrap
//With vanilla js: would need to iterated over all elements returned by .getElementsByClass()
$(".list-example").mouseenter(function() {
unscramble(1000, 25, this, this);
});
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
This does not work properly. This type of animation should not be used on text longer than one line.
I may consider implementing an algorithm to bin similarly sized chars together so that the randomizer can choose chars that won't create large scale displacements
//Example with vanilla js eventListener
var largeExample = document.getElementById("largeExample");
largeExample.addEventListener("click", function() {
unscramble(1000, 25, this, this);
});