有什么方法可以防止水平滚动触发OS X Lion Safari上的向后滑动手势? [英] Any way to prevent horizontal scrolling triggering swipe back gesture on OS X Lion Safari?
问题描述
我正在使用在div
元素中使用水平滚动(使用overflow: scroll
)的UI.我不能向左滚动,因为它会启动动画以使历史回溯.同样,当有网站可以访问时,我无法向右滚动.
I am working on a UI that uses horizontal scrolling in a div
element (using overflow: scroll
). I cannot scroll to the left, because it would start the animation for going back in history. Likewise, I cannot scroll to the right when there is a website to go forward to.
它可以在其他浏览器(包括OS X Lion上的Chrome)上很好地运行,该浏览器还支持滑动以追溯历史. (在我开发的时候,在Safari上也可以在div
中滚动.我添加了事件处理程序和html,它们可能破坏了滚动,但是我不知道是什么使它发生了变化.)
It works well on other browsers including Chrome on OS X Lion, which also supports swiping to go back in history. (At one point while I was developing, scrolling in a div
worked on Safari, too. I've added event handlers and html which probably broke scrolling, but I have no clue what made it change.)
理想情况下,我想在滚动特定的div
时(即使到达末尾时)也可以避免历史上的回溯或前进.
Ideally, I would like to prevent going back or forward in history when scrolling on a specific div
(even when it has reached an end.)
更新:我尝试添加 jQuery.mousewheel ,它以某种方式解决了该问题. (我只是在.mousewheel()
上附加了一个空的事件处理程序.)我仍在寻找明确的答案.
Update: I tried adding jQuery.mousewheel and it somehow fixed the problem. (I just attached a empty event handler on .mousewheel()
.) I am still looking for a definitive answer.
推荐答案
几天来我一直在寻找解决方案.到目前为止,我在此插件中拥有
I've been looking for a solution for days. What I have so far is in this plugin:
https://github.com/micho/jQuery.preventMacBackScroll
当您上下滚动时,它会禁止OSX Chrome浏览器滚动(我找不到为OSX Safari禁用它的方法).
It disabled scrolling for OSX Chrome (I couldn't find a way to disable it for OSX Safari) when you scroll left and up.
我希望能对您有所帮助,请使用发现的所有错误或为Safari禁用这种烦人的行为的方式为该项目做出贡献
I hope that helps, please contribute to the project with any bugs you find, or if you find a way to disable this annoying behavior for Safari
这篇关于有什么方法可以防止水平滚动触发OS X Lion Safari上的向后滑动手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!