Guest User

Untitled

a guest
Jun 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. // feature test for position fixed.
  2.  
  3. Modernizr.addTest('positionfixed', function () {
  4. var test = document.createElement('div'),
  5. control = test.cloneNode(false),
  6. fake = false,
  7. root = document.body || (function () {
  8. fake = true;
  9. return document.documentElement.appendChild(document.createElement('body'));
  10. }());
  11.  
  12. var oldCssText = root.style.cssText;
  13. root.style.cssText = 'padding:0;margin:0';
  14. test.style.cssText = 'position:fixed;top:42px';
  15. root.appendChild(test);
  16. root.appendChild(control);
  17.  
  18. var ret = test.offsetTop !== control.offsetTop;
  19.  
  20. root.removeChild(test);
  21. root.removeChild(control);
  22. root.style.cssText = oldCssText;
  23.  
  24. if (fake) {
  25. document.documentElement.removeChild(root);
  26. }
  27.  
  28. return ret;
  29. });
Add Comment
Please, Sign In to add comment