JavaScripts Effect Code: Falling Text Rotator


SUBMITTED BY: Guest

DATE: Feb. 17, 2014, 3:51 p.m.

FORMAT: Text only

SIZE: 2.2 kB

HITS: 782

  1. Description: This jQuery script adds a twist to the regular text rotator, by randomly dropping the letters of each piece of content out of view before showing the next. It works great on short headlines, with each content wrapped simply in a LI element on the page.
  2. Falling Text Rotator uses the helpful plugin Lettering.js to manipulate text on a character basis, and CSS3 to provide the animation. It works great in all modern versions of FF, Chrome, IE10+ etc, while in IE8/9, it reverts back to a basic rotator with no animation effect.
  3. Directions:
  4. Step 1: Add the following code to the <HEAD> section of your page:
  5. <link rel="stylesheet" type="text/css" href="fallingtextrotator.css" />
  6. <link href='http://fonts.googleapis.com/css?family=Orbitron:400,700,900' rel='stylesheet' type='text/css'>
  7. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  8. <script src="jquery.lettering-0.6.1.min.js"></script>
  9. <script src="fallingtextrotator.js">
  10. /* =====================================
  11. Falling Text Rotator- by JavaScript Kit (www.javascriptkit.com)
  12. Visit JavaScript Kit at http://www.javascriptkit.com/ for full source code
  13. ===================================== */
  14. </script>
  15. <script>
  16. jQuery(function(){ // on DOM load
  17. $('#headline').fallingtextrotator({
  18. pause: 3000,
  19. cycles: 2,
  20. ontextchange:function(msgindex, msg, eachchar){
  21. //console.log(msgindex, msg, eachchar)
  22. }
  23. })
  24. })
  25. </script>
  26. Download the following three external files and upload to same directory as where your webpage resides:
  27. http://www.javascriptkit.com/script/script2/fallingtextrotator.js
  28. http://www.javascriptkit.com/script/script2/fallingtextrotator.css
  29. http://www.javascriptkit.com/script/script2/jquery.lettering-0.6.1.min.js
  30. Step 2: Add the below sample HTML markup to your <BODY>:
  31. <ul id="headline" class="fallingtextrotator" style="height:2em">
  32. <li>JavaScript Kit</li>
  33. <li>Bigger, Bolder</li>
  34. <li>And Badder</li>
  35. <li>Than even Rambo!</li>
  36. </ul>

comments powered by Disqus