Created
February 19, 2025 19:33
-
-
Save jrmuizel/c586e1c2182e9480b9ac57423746aa76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<style> | |
.child { | |
position: absolute; | |
left: 10px; | |
width: 50px; | |
height: 50px; | |
background: lightblue; | |
border: 1px solid black; | |
} | |
.after > .child { | |
width: 100px; | |
height: 100px; | |
left: 100px; | |
} | |
:root { view-transition-name: none } | |
::view-transition-group(*) { | |
animation-duration: 1s; | |
} | |
</style> | |
<div id=container> | |
</div> | |
<script> | |
const params = new URLSearchParams(window.location.search); | |
const complexity = parseInt(params.get('n')) || 1; | |
function constructPage() { | |
let t = 0; | |
for (let i = 0; i < complexity; ++i) { | |
let d = document.createElement("div"); | |
d.style.viewTransitionName = `e${i}`; | |
d.style.top = `${t}px`; | |
d.classList.add("child"); | |
container.appendChild(d); | |
t += Math.max(1, 1000/complexity); | |
} | |
} | |
function runTest() { | |
document.startViewTransition(() => { | |
container.classList.toggle("after"); | |
}); | |
} | |
onload = () => { | |
constructPage(); | |
runTest(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment