android - touchmove event how to disable page scrolling
天蓬老师
天蓬老师 2017-05-16 13:35:17
0
1
748

Recently, a function similar to AssistiveTouch on ios has been made on the H5 page: a small suspended widget that can be moved on the page and automatically adsorbs to the edge when not in use.

Problems that arise:

On Android phones, when you move the widget, the page will scroll accordingly.

Because in order to improve the smoothness of page scrolling in the chrome browser, on the new chrome browser,touchmoveevents cannot be usedevent.preventDefault()to prevent page scrolling.

New binding events need to be handled like this (added apassive: falseattribute)

document.addEventListener('click', onClick, {passive: false, capture: false});

But I use react, and the binding monitor is used directly

touchmove How to prevent the page from scrolling when moving the widget?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all (1)
Ty80

直接来。 资料在这里

Your event handlers will be passed instances of SyntheticEvent, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including stopPropagation() and preventDefault(), except the events work identically across all browsers.

If you find that you need the underlying browser event for some reason, simply use the nativeEvent attribute to get it. Every SyntheticEvent object has the following attributes:

touchmove(event){ event.stopPropagation(); event.nativeEvent.stopImmediatePropagation(); } 或者
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!