Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<title>Sticky-positioned anchor in transformed scroller, chained anchors</title>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<style>
body {
margin: 50px;
}
#scroller {
overflow: hidden;
width: 250px;
height: 250px;
transform-origin: top left;
transform: scale(2);
}
#anchor {
position: sticky;
top: 0;
anchor-name: --foo;
width: 20px;
height: 50px;
background: green;
}
#positioned {
position: absolute;
anchor-name: --bar;
position-anchor: --foo;
position-area: right;
width: 20px;
height: 50px;
background: green;
}
#chained {
position: absolute;
position-anchor: --bar;
position-area: right;
width: 20px;
height: 100px;
background: green;
}
</style>
<div style="width:100px; height:100px; background:red;">
<div id="scroller">
<div style="height:150px;"></div>
<div id="anchor"></div>
<div style="height:1000px;"></div>
<div id="positioned"></div>
</div>
<div id="chained"></div>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
scroller.scrollTop = 160;
promise_test(async t => {
await new Promise(r => requestAnimationFrame(r));
await new Promise(r => requestAnimationFrame(r));
await new Promise(r => requestAnimationFrame(r));
await new Promise(r => requestAnimationFrame(r));
assert_not_equals(document.elementFromPoint(129, 50), chained);
assert_equals(document.elementFromPoint(130, 50), chained);
assert_equals(document.elementFromPoint(149, 149), chained);
assert_not_equals(document.elementFromPoint(149, 150), chained);
}, "Chained anchors");
</script>