jsScrollerTween

Preparation

You just have to have set up either a jsScroller, or jsScrollbar object.

Constructor

new jsScrollerTween(jsScroll, trackTween);

jsScroll can be an instance of jsScroller or jsScrollbar. trackTween is a boolean value that sets whether or not the jsScrollbar will use the tween when the track is clicked.

An example of implementation:

var wrapper = document.getElementById("Scroller");
var barWrapper = document.getElementById("Scrollbar-Container");

var scroller = new jsScroller(wrapper, 400, 200);
var scrollbar = new jsScrollbar(scroller, barWrapper, true);

//use it with the scrollbar, enable track tweening
var scrollTween = new jsScrollerTween(scrollbar, true);

Methods

You should take note, when using these methods, use them with the original jsScrollbar or jsScroller object that was passed. Dont't use them with the jsScrollTween object. The jsScrollTween object just adds more functions to the original object.

.tweenTo(y);

Tweens to the specified y coordinate

.tweenBy(y)

Tweens by a specified amount.

//Tween to the y coordinate 126
//notice I'm using "scrollbar" not "scrollTween"
scrollbar.tweenTo(126);

//Tween up 50px
scrollbar.tweenBy(-50);

Examples

example5.html

Quirks

None that I know of...

Useful Properties

These are properties that you can access that may help you in making scripts:

.steps

This lets you change the tweening steps so you can create your own animation. The steps are defined by the percent of the total distance the tween must travel.

// gradual acceleration and deceleration
scrollTween.steps = 
[0,1,3,6,10,15,21,28,36,45,55,64,72,79,85,90,94,97,99,100];

//Rapid deceleration, this is the default
scrollTween.steps = [0,25,50,70,85,95,97,99,100];

//Straight movement
scrollTween.steps = [0,10,20,30,40,50,60,70,80,90,100];

//Rapid deceleration with a bounce at the end
scrollTween.steps = [0,25,50,70,85,95,100,105,101,97,100,99,100];

._idle

Boolean value that is true when it's not in the middle of an animation.

.stepDelay

The time between the steps in milliseconds. Default is 40.