transform-015.html (1690B)
1 <!DOCTYPE html> 2 <title>Animated transform on anchor ancestor</title> 3 <link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> 4 <link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#determining-position"> 5 <style> 6 #anchor { 7 anchor-name: --a; 8 width: 200px; 9 height: 200px; 10 background: hotpink; 11 } 12 #transformed { 13 width: 500px; 14 transform: translateX(0); 15 background: yellow; 16 } 17 #anchored { 18 position: absolute; 19 position-anchor: --a; 20 position-area: bottom right; 21 width: 100%; 22 height: 100%; 23 background: cyan; 24 } 25 @keyframes anim { 26 from { transform: translateX(0) } 27 to { transform: translateX(200px) } 28 } 29 </style> 30 <div style="contain:layout; width:400px; height:400px;"> 31 <div> 32 <div id="transformed"> 33 <div> 34 <div id="anchor"></div> 35 </div> 36 </div> 37 </div> 38 <div id="anchored"></div> 39 </div> 40 41 <script src="/resources/testharness.js"></script> 42 <script src="/resources/testharnessreport.js"></script> 43 <script> 44 const done = Promise.withResolvers(); 45 let got_halfway = false; 46 const observer = new ResizeObserver((entries)=> { 47 assert_equals(entries.length, 1); 48 const inlineSize = entries[0].contentBoxSize[0].inlineSize; 49 if (inlineSize > 30 && inlineSize < 170) { 50 got_halfway = true; 51 done.resolve(); 52 } 53 }); 54 anchor.onanimationend = ()=> { done.reject(); } 55 56 promise_test(async t => { 57 transformed.style.animation = "2000ms linear anim"; 58 observer.observe(anchored); 59 try { await done.promise; } catch(e) {} 60 assert_true(got_halfway, "animation frame somewhere in the middle"); 61 }, "Animation being updated"); 62 </script>