Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<title>Animated anchor transform</title>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<style>
#anchor {
anchor-name: --a;
width: 200px;
height: 200px;
rotate: 30deg;
background: hotpink;
}
#anchored {
position: absolute;
position-anchor: --a;
position-area: bottom right;
width: 100%;
height: 100%;
background: cyan;
}
@keyframes anim {
from { rotate: 30deg; }
to { rotate: 0deg; }
}
</style>
<div style="contain:layout; width:300px; height:400px;">
<div id="anchor"></div>
<div id="anchored"></div>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const done = Promise.withResolvers();
let got_halfway = false;
const observer = new ResizeObserver((entries)=> {
assert_equals(entries.length, 1);
const inlineSize = entries[0].contentBoxSize[0].inlineSize;
if (inlineSize > 66 && inlineSize < 94) {
got_halfway = true;
done.resolve();
}
});
anchor.onanimationend = ()=> { done.reject(); }
promise_test(async t => {
anchor.style.animation = "2000ms linear anim";
observer.observe(anchored);
try { await done.promise; } catch(e) {}
assert_true(got_halfway, "animation frame somewhere in the middle");
}, "Animation being updated");
</script>