问题
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