| OLD | NEW |
| 1 <script> | 1 <script> |
| 2 onload = function() { | 2 onload = function() { |
| 3 scroller.scrollTop = 100; | 3 scroller.scrollTop = 100; |
| 4 } | 4 } |
| 5 </script> | 5 </script> |
| 6 <style> | 6 <style> |
| 7 .composited { |
| 8 will-change: transform; |
| 9 } |
| 10 |
| 7 #scroller { | 11 #scroller { |
| 8 /* Opaque background means scroller is composited. */ | |
| 9 background: white; | |
| 10 height: 200px; | 12 height: 200px; |
| 11 overflow: auto; | 13 overflow: auto; |
| 12 width: 200px; | 14 width: 200px; |
| 13 } | 15 } |
| 16 |
| 14 .sticky { | 17 .sticky { |
| 15 position: sticky; | 18 position: sticky; |
| 16 top: 0; | 19 top: 0; |
| 17 height: 50px; | 20 height: 50px; |
| 18 /* Opaque background means sticky element is composited. */ | |
| 19 background: green; | 21 background: green; |
| 20 } | 22 } |
| 21 .spacer { | 23 .spacer { |
| 22 height: 2000px; | 24 height: 2000px; |
| 23 } | 25 } |
| 24 </style> | 26 </style> |
| 25 <div id="scroller"> | 27 <div id="scroller" class="composited"> |
| 26 <div class="sticky"></div> | 28 <div class="composited sticky"></div> |
| 27 <div class="spacer"></div> | 29 <div class="spacer"></div> |
| 28 </div> | 30 </div> |
| OLD | NEW |