Created
August 13, 2020 03:11
-
-
Save Inontran/68579eb2cc348d27a14009fcaa260854 to your computer and use it in GitHub Desktop.
проверка на поддержку passive
This file contains hidden or 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
| var passiveSupported = false; | |
| try { | |
| window.addEventListener( | |
| "test", | |
| null, | |
| Object.defineProperty({}, "passive", { get: function() { passiveSupported = true; } })); | |
| // console.log('passiveSupported == ' + passiveSupported); | |
| } catch(err) {} | |
| document.addEventListener('scroll', function(){ | |
| }, | |
| passiveSupported ? { passive: true } : false | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment