Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html class="reftest-wait">
<title>View transitions: Test pagereveal.ready</title>
<link rel="author" href="mailto:bokan@chromium.org">
<link rel="match" href="pagereveal-ready-promise-ref.html">
<script src="/common/reftest-wait.js"></script>
<script>
const params = new URLSearchParams(location.search);
const is_new_page = params.has('new');
if (is_new_page) {
document.documentElement.classList.add('newPage');
addEventListener('pagereveal', e => {
e.viewTransition.ready.then(() => {
document.getAnimations().forEach(anim => anim.pause());
requestAnimationFrame(() => requestAnimationFrame(takeScreenshot));
});
});
} else {
onload = () => {
requestAnimationFrame(() => requestAnimationFrame(() => {
location.replace(location.href + '?new');
}));
};
}
</script>
<style>
@view-transition {
navigation: auto;
}
#target {
width: 100px;
height: 100px;
background-color: limegreen;
position: absolute;
left: 20px;
top: 100px;
view-transition-name: target;
}
.newPage #target {
left: 300px;
}
/* Ensure view-transition snapshots are easily distinguished from live DOM */
:root {
view-transition-name: unset;
}
::view-transition {
background-color: thistle;
}
</style>
<div id="target"></div>
</html>