9

I have a UI where users are scrolling a horizontally scrolling area.

I still want them to be able to scroll left and right, but I'd like to fire an Hammer.js pan event at the same time. Here's my code at present:

var worksHammertime = new Hammer(scrollingArea);
worksHammertime.on('pan', function(ev) {
  if ( ev.direction === 2 ) {
    log('left', ev)
    Do things...
  } else {
    log('right', ev)
    Do things...
  }
});

Essentially I think I'm looking for the opposite of the preventDefault()behaviour that Hammer seems to use by default. Can use hammer.js pan events and still allow users to scroll?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494

2 Answers2

5

Apply a CSS property:

#touch-area
{
touch-action: pan-x pan-y !important;
}
bummi
  • 27,123
  • 14
  • 62
  • 101
Ashish Maradiya
  • 113
  • 1
  • 8
0

This currently isn't supported, but you could try to do this with a nested element containing style="overflow: auto;"

Jorik
  • 641
  • 5
  • 6