JS text unscramble animator


Dynamic example with custom configurations

Result:

Text To Scramble

Code:
$("#textToScramble").on("input", function() {
  //need to move input value to a text-holding element.
  $("#scrambleTestResult").text($(this).val());
});
//Example showing how to use the trigger from a different event/element.
$("#scrambleTestSubmit").click(function() {
  var element = document.getElementById("scrambleTestResult");
  unscramble($("#unscrambleSpeed").val(), $("#randomizerSpeed").val(), element, element);
})

An example showing the source text element and target text element being different

Input:

Pass this along to some other place!

Result:

Code:
$("#targetSourceSubmit").click(function() {
  var sourceElement = document.getElementById("sourceExample");
  var targetElement = document.getElementById("targetExample");
  unscramble(2000, 25, sourceElement, targetElement);
})

An example using a list all sharing the same class with an attached event listener (Hover to activate)

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

Code:
//With vanilla js: would need to iterated over all elements returned by .getElementsByClass()
$(".list-example").mouseenter(function() {
  unscramble(1000, 25, this, this);
});

An example using a large section of text. (Click text to activate)

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.

Code:
//Example with vanilla js eventListener
var largeExample = document.getElementById("largeExample");
largeExample.addEventListener("click", function() {
  unscramble(1000, 25, this, this);
});