daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top