Last active
December 15, 2019 09:32
-
-
Save tk-o/afb6d638d730d8e9ce278e3df2b15552 to your computer and use it in GitHub Desktop.
supports position: sticky in javascript #learninpublic
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
// es-5 compatible | |
function supportsPositionSticky() { | |
var element = document.createElement('div'); | |
return ['', '-o-', '-webkit-', '-moz-', '-ms-'].filter(function(prefix) { | |
element.style.position = prefix + 'sticky'; | |
return element.style.position === 'sticky'; | |
}).length !== 0; | |
} | |
// es-next compatible | |
function supportsPositionSticky() { | |
const element = document.createElement('div'); | |
return ['', '-o-', '-webkit-', '-moz-', '-ms-'].some(prefix => { | |
element.style.position = prefix + 'sticky'; | |
return element.style.position === 'sticky'; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment