transform-012.html (1478B)
1 <!DOCTYPE html> 2 <title>Animated anchor transform</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 scale: 0.5; 11 background: hotpink; 12 } 13 #anchored { 14 position: absolute; 15 position-anchor: --a; 16 position-area: bottom right; 17 width: 100%; 18 height: 100%; 19 background: cyan; 20 } 21 @keyframes anim { 22 from { scale: 0.5; } 23 to { scale: 2; } 24 } 25 </style> 26 <div style="contain:layout; width:300px; height:400px;"> 27 <div id="anchor"></div> 28 <div id="anchored"></div> 29 </div> 30 31 <script src="/resources/testharness.js"></script> 32 <script src="/resources/testharnessreport.js"></script> 33 <script> 34 const done = Promise.withResolvers(); 35 let got_halfway = false; 36 const observer = new ResizeObserver((entries)=> { 37 assert_equals(entries.length, 1); 38 const inlineSize = entries[0].contentBoxSize[0].inlineSize; 39 if (inlineSize > 40 && inlineSize < 110) { 40 got_halfway = true; 41 done.resolve(); 42 } 43 }); 44 anchor.onanimationend = ()=> { done.reject(); } 45 46 promise_test(async t => { 47 anchor.style.animation = "2000ms linear anim"; 48 observer.observe(anchored); 49 try { await done.promise; } catch(e) {} 50 assert_true(got_halfway, "animation frame somewhere in the middle"); 51 }, "Animation being updated"); 52 </script>