0

I've got problem with touchpad scrolling. This is how looks my site: click. You can navigate here using up/down arrows, menu and mouse wheel. Everything is fine except scrolling using touchpad. When you do this, it's interpreted just like few scrolls of mouse wheel. So you don't go from the top to second screen but to the last one. I was thinking about it and my solutions is:

  • detect direction of scroll
  • scroll to next/prev screen
  • stop scrolling

But I don't have any idea how to "stop scrolling". Can anyone help me? :)

MrShemek
  • 13
  • 1
  • 3

1 Answers1

0

Ok, i've figured out how to do this. Maybe it isn't the best way but it works. The code:

        scrollTimes ={ 
            up : 0,
            down : 0
        };

         $('body').bind('DOMMouseScroll', function(e){
            if(e.originalEvent.detail > 0) {
               scrollTimes.down++;
                if(scrollTimes.down === 1 ) {
                    api.next(2000);
                }
            }
            else {
                scrollTimes.up++;
                if(scrollTimes.up === 1 ) {
                    api.prev(2000);
                }
            }

            setTimeout( function() { scrollTimes = { up : 0, down : 0};}, 2000);

            return false;
        });

        $('body').bind('mousewheel', function(e){
            if(e.originalEvent.wheelDelta < 0) {
                scrollTimes.down++;
                if(scrollTimes.down === 1 ) {
                    api.next(2000);
                }
            }
            else {
                scrollTimes.up++;
                if(scrollTimes.up === 1 ) {
                    api.prev(2000);
                }
            }

            setTimeout( function() { scrollTimes = { up : 0, down : 0};}, 2000);

            return false;
        });

I've set time in setTimeout to 2000 because it's the time of scrolling to next/prev screen :)

MrShemek
  • 13
  • 1
  • 3