Guest User

Untitled

a guest
May 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. var scroller = {
  2. frame: 0,
  3. frame2: 0.1,
  4. amplitude1: 10,
  5. offset: 0.2,
  6. sinescroll: function(target){
  7. scrolltext = $(target).text();
  8. $(target).text("");
  9.  
  10. // write DIVs to hold characters
  11. for (var i = 0; i < scrolltext.length; i++)
  12. {
  13. var appendText = scrolltext[i];
  14. if(scrolltext[i] == " "){
  15. appendText = "&nbsp;";
  16. }
  17. $(target).append('<div class="scroller_sub" id="scroller_sub_'+i+'">'+appendText+'</div>');
  18. //position everything correctly
  19. var last_left = 0;
  20. $('.scroller_sub').each(function(){
  21. $(this).css('left', last_left);
  22. last_left += $(this).width();
  23. }).css({position:'absolute', top:'0px'});
  24. }
  25. },
  26. step: function(){
  27. var angle = this.frame;
  28. var offset = this.offset;
  29. var amplitude1 = this.amplitude1;
  30. $('.scroller_sub').each(function(){
  31. var top = amplitude1 * Math.sin(angle);
  32. $(this).css('top', top);
  33. angle += offset;
  34. });
  35. this.frame += this.frame2;
  36. }
  37. };
Add Comment
Please, Sign In to add comment