Quantcast
Channel: User JohnP - Stack Overflow
Viewing all articles
Browse latest Browse all 37

Answer by JohnP for Hammer.js breaks vertical scroll when horizontal pan

$
0
0

User patforna is correct. You need to adjust the touch-action property. This will fix scrolling not working when you have hammer bound on a big element in mobile.

You create a Hammer instance like so

var h = new Hammer(options.contentEl, {    touchAction : 'auto'});

I was working on a pull to refresh feature, so I need the pan event.

Add the recognizers.

h.get( 'pan' ).set({    direction   : Hammer.DIRECTION_VERTICAL,});h.on('panstart pandown panup panend', eventHandler);

Inside the eventhandler, you'd look at the event that was triggered and manually call on event.preventDefault() when you require it. This is applicable for hammer 2.0.6.

For anyone who's looking the pull to refresh code was taken from - https://github.com/apeatling/web-pull-to-refresh


Viewing all articles
Browse latest Browse all 37

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>