Skip to content

Instantly share code, notes, and snippets.

@johanneslumpe
Last active August 29, 2015 14:00
Show Gist options
  • Save johanneslumpe/11139066 to your computer and use it in GitHub Desktop.
Save johanneslumpe/11139066 to your computer and use it in GitHub Desktop.
Fullsize background videos in webkit browsers gist 6
// quick and dirty check for webkit, which has a bug that it does not compute the
// proper scrollTop, when overflowX is set on the body. We can use this to decide
// when we have to disable fixed-attachment backgrounds, because they lead to a rendering
// issue in webkit. This test is just a naive implementation and probably could be improved
// but works fine for now.
var overflowScrollTopBuggy = function overflowScrollTopBuggy () {
if (testFixedBackgrounds.buggy) {
return testFixedBackgrounds.buggy;
}
var body = document.querySelector('body');
var s = document.createElement('style');
s.innerHTML = 'html,body {overflow-x: hidden;}';
body.appendChild(s);
body.scrollTop = 1;
overflowScrollTopBuggy.buggy = (body.scrollTop === 0);
body.scrollTop = 0;
body.removeChild(s);
return overflowScrollTopBuggy.buggy;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment