Guest User

Untitled

a guest
Sep 21st, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. /************************************************************************
  2.  
  3. How to use:
  4.  
  5. // make a new instance of the scroller
  6. button = new scroller(
  7. $('#button_ID'), // grab a dom element n wrap with jquery
  8. 0, // set the scroll position
  9. 500 // set the scroll speed
  10. );
  11.  
  12. // initiate the animator on the button
  13. button.animator();
  14.  
  15. // to disable the button
  16. button.disabler();
  17.  
  18. ************************************************************************/
  19.  
  20. (function() {
  21.  
  22. scroller = function(button, pos, speed) {
  23. if (pos == null) pos = 230;
  24. if (speed == null) speed = 50;
  25. this.button = button;
  26. this.pos = pos;
  27. this.speed = speed;
  28. return this;
  29. };
  30.  
  31. scroller.prototype.animator = function() {
  32. var speed, pos;
  33. pos = this.pos;
  34. speed = this.speed;
  35. return this.button.on('click.scroller', function() {
  36. return $('body, html').animate({
  37. scrollTop: pos
  38. }, speed, 'swing');
  39. });
  40. };
  41.  
  42. scroller.prototype.disabler = function() {
  43. return this.button.off('click.scroller');
  44. };
  45.  
  46. })();
Add Comment
Please, Sign In to add comment