You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a big/computation intensive touchStart, touchMove handler could block following scroll event.
Developers can now annotate touch and wheel listeners with {passive: true} to indicate that they will never invoke preventDefault. This feature shipped in Chrome 51, Firefox 49 and landed in WebKit.
in Chrome for Android 80% of the touch events that block scrolling never actually prevent it. 10% of these events add more than 100ms of delay to the start of scrolling, and a catastrophic delay of at least 500ms occurs in 1% of scrolls.
// Test via a getter in the options object to see // if the passive property is accessedvarsupportsPassive=false;try{varopts=Object.defineProperty({},'passive',{get: function(){supportsPassive=true;}});window.addEventListener("test",null,opts);}catch(e){}// Use our detect's results. // passive applied if supported, capture will be false either way.elem.addEventListener('touchstart',fn,supportsPassive ? {passive: true} : false);
a big/computation intensive
touchStart, touchMove
handler could block following scroll event.Developers can now annotate touch and wheel listeners with
{passive: true}
to indicate that they will never invokepreventDefault
. This feature shipped in Chrome 51, Firefox 49 and landed in WebKit.spec:
https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
https://dom.spec.whatwg.org/#dom-eventlisteneroptions-passive
scroll performance comparison between passive:true and false
https://www.youtube.com/watch?v=NPM6172J22g
polyfill
react is yet to support passive event
facebook/react#6436
The text was updated successfully, but these errors were encountered: