-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When supported, mark scroll listener as passive (#45)
* feat: Implement passive listener feature detection * feat(scroll): When supported, mark scroll listener as passive Closes #38
- Loading branch information
1 parent
fdac745
commit 59404c6
Showing
2 changed files
with
17 additions
and
1 deletion.
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
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,11 @@ | ||
export let supportsPassiveListener = false; | ||
|
||
try { | ||
const opts = Object.defineProperty({}, 'passive', { | ||
get: function() { | ||
supportsPassiveListener = true; | ||
}, | ||
}); | ||
(window as EventTarget).addEventListener('testPassive', null, opts); | ||
(window as EventTarget).removeEventListener('testPassive', null, opts); | ||
} catch (e) {} |