Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /scroll-animations/responsive/repaint-after-finished.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="match" href="repaint-after-finished-ref.html">
<title>View-timeline repaint after finished</title>
<style>
.row {
display: flex;
gap: 10px;
align-items:
flex-start;
}
.scroll-self, .scroll, .view {
width: 100px;
height: 100px;
margin: 10px;
overflow: auto;
}
.scroll-self {
display: grid;
grid-template-columns: 200px;
}
.scroll::after, .view::after {
content: '';
height: 100px;
display: grid;
grid-template-columns: 200px;
}
.view::after {
animation-range: contain cover;
}
.scroll-self {
animation-timeline: scroll(self x);
}
.scroll::after {
animation-timeline: scroll(x);
}
.view::after {
animation-timeline: view(x);
}
.bg .scroll-self, .bg .scroll::after, .bg .view::after {
animation-name: bg;
}
@keyframes bg {
from { background-color: red; }
to { background-color: blue; }
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/web-animations/testcommon.js"></script>
</head>
<div class="row bg">
<div id="t1" class="scroll-self"></div>
<div id="t2" class="scroll"></div>
<div id="t3" class="view"></div>
</div>
<script>
window.onload = async () => {
const anims = document.getAnimations();
await Promise.all(anims.map(a => a.ready));
await runAndWaitForFrameUpdate(() => {
['t1', 't2', 't3'].forEach(name => {
const element = document.getElementById(name);
element.scrollLeft = element.scrollWidth - element.clientWidth;
});
});
await Promise.all(anims.map(a => a.finished));
await runAndWaitForFrameUpdate(() => {
['t1', 't2', 't3'].forEach(name => {
const element = document.getElementById(name);
// Still off screen and in the 'after' phase after the first update.
element.scrollLeft = element.scrollLeft - 1;
});
});
await runAndWaitForFrameUpdate(() => {
['t1', 't2', 't3'].forEach(name => {
const element = document.getElementById(name);
element.scrollLeft = 0;
});
});
takeScreenshot();
};
</script>
</html>