Advertisement
Guest User

Untitled

a guest
Sep 11th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var scrollHandle = 0,
  2.     scrollStep = 5,
  3.     parent = jQuery("#hatListSubContainer");
  4.  
  5. //Start the scrolling process
  6. jQuery(".panner").on("mousedown", function () {
  7.     console.log('click');
  8.     var data = jQuery(this).data('scroll-modifier'),
  9.         direction = parseInt(data, 10);
  10.  
  11.     jQuery(this).addClass('active');
  12.  
  13.     startScrolling(direction, scrollStep);
  14. });
  15.  
  16. //Kill the scrolling
  17. jQuery(".panner").on("mouseup", function () {
  18.     stopScrolling();
  19.     jQuery(this).removeClass('active');
  20. });
  21.  
  22. //Actual handling of the scrolling
  23. function startScrolling(modifier, scrollStep) {
  24.     if (scrollHandle === 0) {
  25.         scrollHandle = setInterval(function () {
  26.             var newOffset = parent.scrollLeft() + (scrollStep * modifier);
  27.  
  28.             parent.scrollLeft(newOffset);
  29.            
  30.             console.log('startScrolling' + newOffset);
  31.            
  32.         }, 10);
  33.     }
  34. }
  35.  
  36. function stopScrolling() {
  37.     clearInterval(scrollHandle);
  38.     scrollHandle = 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement