ladybird/Tests/LibWeb/Text/input/WebAnimations/cancel-animation-when-element-moves-in-display-none-subtree.html
Aliaksandr Kalenik b92a8553c7 LibWeb: Cancel animations when element is moved in display none subtree
We already have logic to play or cancel animations in an element's
subtree when the display property changes to or from none. However,
this was not sufficient to cover the case when an element starts/stops
being nested in display none after insertion.
2025-03-04 18:06:46 +01:00

59 lines
No EOL
1.4 KiB
HTML

<!DOCTYPE html>
<head>
<style>
.animated-box {
width: 50px;
height: 50px;
background-color: coral;
animation: move 2s linear infinite;
}
@keyframes move {
0% {
transform: translateX(0);
}
50% {
transform: translateX(100px);
}
100% {
transform: translateX(0);
}
}
.hidden-container {
display: none;
}
</style>
<script src="../include.js"></script>
</head>
<body>
<div id="visible-container">
<div class="animated-box" id="animated-box"></div>
</div>
<div id="hidden-container" class="hidden-container">
</div>
<script>
asyncTest(done => {
requestAnimationFrame(() => {
const animatedBox = document.getElementById('animated-box');
const hiddenContainer = document.getElementById('hidden-container');
const animationsCountBefore = document.getAnimations().length;
hiddenContainer.appendChild(animatedBox);
const animationsCountAfter = document.getAnimations().length;
println('Animations count before: ' + animationsCountBefore);
println('Animations count after: ' + animationsCountAfter);
done();
});
});
</script>
</body>
</html>