react-anchor-navigation
Version:
React lightweight library for anchor scrolling and navigation tied to URL hash.
22 lines (18 loc) • 578 B
text/typescript
// Passive event support
// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
export const SUPPORT_PASSIVE_EVENT =
typeof addEventListener !== 'undefined' &&
(() => {
let supportsPassiveOption = false;
try {
const noop = () => {};
const opts = Object.defineProperty({}, "passive", {
get: () => (supportsPassiveOption = true)
});
addEventListener("testPassive", noop, opts);
removeEventListener("testPassive", noop, opts);
} catch (e) {
// error
}
return supportsPassiveOption;
})();