HammerJS v2< div> 'overflow-y:auto'不会在ipad上滚动 [英] HammerJS v2 <div> with 'overflow-y: auto' does not scroll on ipad

查看:138
本文介绍了HammerJS v2< div> 'overflow-y:auto'不会在ipad上滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HammerJS v2的页面。我的布局看起来像:

I have a page with HammerJS v2 on it. My layout looks like:

body - overflow: hidden
    div1 - overflow: hidden (this is always the size of the viewport)
        div2 - overflow-y: auto
    div1 - overflow: hidden (this is always the size of the viewport)
        div2 - overflow-y: auto

div2在内容溢出时会显示一个滚动条,但是当试图在safari或chrome上滚动iPad时,工作。在Android设备上,它似乎可以正常工作。

div2 shows a scrollbar when it has overflowed content, however, when trying to scroll on an iPad in safari or chrome, it doesn't work. On android devices it seems to work OK.

在div1上滑动时,它会将您带到下一个div1。

When you swipe on div1, it will take you to the next div1.

我曾尝试设置锤子设置:

I have tried setting the hammer setting:

Hammer.defaults.touchAction = "pan-y";

但是,这开始允许滚动整个文档,我不希望这样。

But this starts allowing scrolling of the whole document, and I don't want that. I just want to scroll div2.

还有其他人遇到过这个问题,或者有什么想法可以做到吗?

has anyone else came across this issue, or have any ideas what it could be?

推荐答案

我通过设置解决了这个问题:

I solved this by setting:

Hammer.defaults.touchAction = "compute";

我还必须在模拟滚动的div2上放置泛事件。我使用下面的文章来模仿滚动: http ://ariya.ofilabs.com/2013/08/javascript-kinetic-scrolling-part-1.html

I also had to put a pan event on div2's that mimic the scroll. I used the following article to help with mimicking the scroll: http://ariya.ofilabs.com/2013/08/javascript-kinetic-scrolling-part-1.html

这篇关于HammerJS v2< div> 'overflow-y:auto'不会在ipad上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆