Created
July 8, 2010 20:28
-
-
Save jonbro/468569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scroller = { | |
frame: 0, | |
frame2: 0.1, | |
amplitude1: 10, | |
offset: 0.2, | |
sinescroll: function(target){ | |
scrolltext = $(target).text(); | |
$(target).text(""); | |
// write DIVs to hold characters | |
for (var i = 0; i < scrolltext.length; i++) | |
{ | |
var appendText = scrolltext[i]; | |
if(scrolltext[i] == " "){ | |
appendText = " "; | |
} | |
$(target).append('<div class="scroller_sub" id="scroller_sub_'+i+'">'+appendText+'</div>'); | |
//position everything correctly | |
var last_left = 0; | |
$('.scroller_sub').each(function(){ | |
$(this).css('left', last_left); | |
last_left += $(this).width(); | |
}).css({position:'absolute', top:'0px'}); | |
} | |
}, | |
step: function(){ | |
var angle = this.frame; | |
var offset = this.offset; | |
var amplitude1 = this.amplitude1; | |
$('.scroller_sub').each(function(){ | |
var top = amplitude1 * Math.sin(angle); | |
$(this).css('top', top); | |
angle += offset; | |
}); | |
this.frame += this.frame2; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment