Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script> | |
| 3 if (window.internals) { | |
| 4 internals.settings.setCSSStickyPositionEnabled(true); | |
| 5 } | |
| 6 </script> | |
| 7 | |
| 8 <html> | |
| 9 <head> | |
| 10 <style> | |
| 11 body { | |
| 12 margin: 0; | |
| 13 overflow: hidden; /* hide scrollbars */ | |
|
flackr
2017/02/22 15:43:02
I just noticed this, isn't this making the body an
smcgruer
2017/02/22 16:14:22
As per discussion, this is actually ok because the
| |
| 14 } | |
| 15 | |
| 16 .container { | |
| 17 height: 2000px; | |
| 18 } | |
| 19 | |
| 20 .box { | |
| 21 height: 50px; | |
| 22 } | |
| 23 | |
| 24 .sticky { | |
| 25 position: sticky; | |
| 26 top: 50px; | |
| 27 background-color: green; | |
| 28 } | |
| 29 </style> | |
| 30 <script> | |
| 31 if (window.testRunner) | |
| 32 testRunner.waitUntilDone() | |
| 33 | |
| 34 function doTest() | |
| 35 { | |
| 36 const sticky = document.querySelector('.sticky'); | |
| 37 sticky.style.position = 'relative'; | |
| 38 | |
| 39 // Force layout. | |
| 40 sticky.offsetTop; | |
| 41 | |
| 42 sticky.style.position = 'sticky'; | |
| 43 | |
| 44 window.requestAnimationFrame(function() { | |
| 45 window.scrollTo(0, 100); | |
| 46 if (window.testRunner) | |
| 47 testRunner.notifyDone(); | |
| 48 }); | |
| 49 } | |
| 50 | |
| 51 window.addEventListener('load', function() { | |
| 52 // We require the compositings inputs to be clean (and thus the initial | |
| 53 // sticky position to be calculated) before we stat changing things. | |
| 54 // Force this by waiting for a double rAF. | |
| 55 window.requestAnimationFrame(function() { | |
| 56 window.requestAnimationFrame(function() { | |
| 57 doTest(); | |
|
flackr
2017/02/22 15:43:01
nit: just requestAnimationFrame(doTest); for the i
smcgruer
2017/02/22 16:14:22
Done.
| |
| 58 }); | |
| 59 }); | |
| 60 }); | |
| 61 </script> | |
| 62 </head> | |
| 63 <body> | |
| 64 <div class="container"> | |
| 65 <div class="sticky box"></div> | |
| 66 </div> | |
| 67 </body> | |
| 68 </html> | |
| OLD | NEW |