1

I am creating a web app that uses the jquery.mousewheel.js plugin to detect the user's mousewheel and then scroll between the two sections.

The body element is also set to overflow:hidden so I can't detect a scroll event.

It works perfectly on the desktop but I've tried it on iPhone and it doesn't trigger the mouse wheel event at all. So is there some sort of add-on to the plugin I am using or an alternative event I can listen for, that will tell me when the user tries to scroll down/up vertically?

dda
  • 6,030
  • 2
  • 25
  • 34
Shannon
  • 843
  • 6
  • 22

2 Answers2

0

Using something like Hammer.js you can detect swipes via swipeup & swipedown events, and it even includes a jquery plugin so you can just write the following:

$("html, body").hammer().on("swipedown", function(e) {
    // do scroll up stuff

});

$("html, body").hammer().on("swipeup", function(e) {
    // do scroll down stuff

});
Shannon
  • 843
  • 6
  • 22
0

You can capture the gestures with HammerJS, but then you have to code the scrolling yourself. Another option is to use iScroll with probing enabled, letting you capture the scroll position without interfering. More here:

javascript scroll event for iPhone/iPad?

Community
  • 1
  • 1