Can use hammer.js pan events and still allow users to scroll?

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?


应用CSS属性:

#touch-area
{
touch-action: pan-x pan-y !important;
}

目前不支持,但你可以尝试使用包含style="overflow: auto;"的嵌套元素来做到这一点style="overflow: auto;"

链接地址: http://www.djcxy.com/p/80476.html

上一篇: 上传的文件只包含“WebKitFormBoundary”

下一篇: 可以使用hammer.js平移事件并仍然允许用户滚动?