触摸移动某个元素时禁用滚动 [英] Disable scrolling when touch moving certain element

查看:348
本文介绍了触摸移动某个元素时禁用滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中有一个部分用于绘制图画。但是,在移动浏览器上使用时,touchmove事件(至少是垂直事件)也会滚动页面(这会降低草图体验的质量)。是否有办法a)禁用&重新启用页面的滚动(所以我可以在每行开始时将其关闭,但在每次完成后将其重新打开),或b)禁用touchmove事件的默认处理(可能是滚动)绘制草图的画布(我不能完全禁用它们,因为草图使用它们)?

I have a page with a section to sketch a drawing in. But the touchmove events, at least the vertical ones, are also scrolling the page (which degrades the sketching experience) when using it on a mobile browser. Is there a way to either a) disable & re-enable the scrolling of the page (so I can turn it off when each line is started, but turn it back on after each is done), or b) disable the default handling of touchmove events (and presumably the scrolling) that go to the canvas the sketch is drawn in (I can't just disable them completely, as the sketching uses them)?

我使用了jquery-mobile vmouse处理程序草图,如果这有所不同。

I've used jquery-mobile vmouse handlers for the sketch, if that makes a difference.

更新:在iPhone上,如果我选择要绘制的画布,或者只是按住在绘图之前我的手指有点,页面不会滚动,而不是因为我在页面中编码的任何内容。

Update: On an iPhone, if I select the canvas to be sketched in, or just hold my finger for a bit before drawing, the page doesn't scroll, and not because of anything I coded in the page.

推荐答案

Hallodorn回答如何暂时禁用滚动?(令人惊讶的是,这不是接受的答案)为我做了诀窍。

Hallodorn's answer to How to disable scrolling temporarily? (which, surprisingly, WASN'T the accepted answer) did the trick for me.

这篇关于触摸移动某个元素时禁用滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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