Unable to preventDefault inside passive event listener - Swipebox Mobie

孤街浪徒 提交于 2019-12-11 05:30:57

问题


I'm using Swipebox : http://brutaldesign.github.io/swipebox/ I know that I can open a content with swipebox slide like that

// Link to click
<a href="#mydiv" class="my-swipebox">Click to show</a>

// And the div in html
<div id="#mydiv">Click <a href="http://example.com">Here</div>

The problem is I can't click the link inside this div when it opened by swipebox on mobie (on desktop it working very fine)

The chrome browser show this log :

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080
preventDefault @ js_3q9o_g1v9VMwOb38KwiIL35eXGTsWaJ31hpdemJVNbY.js:5
dispatch @ js_3q9o_g1v9VMwOb38KwiIL35eXGTsWaJ31hpdemJVNbY.js:5
v.handle @ js_3q9o_g1v9VMwOb38KwiIL35eXGTsWaJ31hpdemJVNbY.js:5

How can I fix this problem, thank you so much


回答1:


A passive event listener is an event where you promise the browser that you will never invoke event.preventDefault(). That way the browser can optimize actions like scrolling/touches because the browser can assume the developer will not be cancelled out (e.g. disabling scrolling).

Chrome enables this by default as per version 56: https://www.chromestatus.com/features/5093566007214080. They made this change as a way to optimize scrolling.

If you do not want to this to happen, you can add { passive: false } as the third argument to .addEventListener.

Read more about passive events at: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md



来源:https://stackoverflow.com/questions/45120638/unable-to-preventdefault-inside-passive-event-listener-swipebox-mobie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!