matthewp / position--sticky-

Polyfill for position: sticky;
175 stars 34 forks source link

Polyfill is active even if the browser supports position: sticky #2

Closed jpa00 closed 11 years ago

jpa00 commented 11 years ago

Maybe add something like this to the start of the function?

var prefixTestList = ['', '-webkit-', '-ms-', '-moz-', '-o-'];
var stickyTestElement = document.createElement('div');

for (var i = 0; i < prefixTestList.length; i++) {
  stickyTestElement.style.position = prefixTestList[i] + 'sticky';
  if (stickyTestElement.style.position != '')
    return;
}
matthewp commented 11 years ago

Good idea, I'll take a look at this soon.