-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect passive event support and try to use it only if its available
- Loading branch information
Showing
4 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// ideally will get replaced with external dep | ||
// when rafrex/detect-passive-events#4 and rafrex/detect-passive-events#5 get merged in | ||
export const testPassiveEventSupport = () => { | ||
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') { | ||
return; | ||
} | ||
|
||
let passive = false; | ||
|
||
const options = Object.defineProperty({}, 'passive', { | ||
get() { | ||
passive = true; | ||
}, | ||
}); | ||
|
||
const noop = () => {}; | ||
|
||
window.addEventListener('testPassiveEventSupport', noop, options); | ||
window.removeEventListener('testPassiveEventSupport', noop, options); | ||
|
||
return passive; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters