Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************************************************************
- How to use:
- // make a new instance of the scroller
- button = new scroller(
- $('#button_ID'), // grab a dom element n wrap with jquery
- 0, // set the scroll position
- 500 // set the scroll speed
- );
- // initiate the animator on the button
- button.animator();
- // to disable the button
- button.disabler();
- ************************************************************************/
- (function() {
- scroller = function(button, pos, speed) {
- if (pos == null) pos = 230;
- if (speed == null) speed = 50;
- this.button = button;
- this.pos = pos;
- this.speed = speed;
- return this;
- };
- scroller.prototype.animator = function() {
- var speed, pos;
- pos = this.pos;
- speed = this.speed;
- return this.button.on('click.scroller', function() {
- return $('body, html').animate({
- scrollTop: pos
- }, speed, 'swing');
- });
- };
- scroller.prototype.disabler = function() {
- return this.button.off('click.scroller');
- };
- })();
Add Comment
Please, Sign In to add comment