Skip to content

Commit 3325432

Browse files
David Awogbemilachromium-wpt-export-bot
authored andcommitted
[animation-trigger] Ensure getAnimations includes yet-to-trigger animations
getAnimations should account for animations which could still be played due to their having a trigger. The current intent is to modify "relevant animations" (which is what getAnimations returns) using the criteria at [1]. [1] w3c/csswg-drafts#11971 (comment) Bug: 406190895, 390314945 Change-Id: I41183fb7ba14df9218ca1360b0f890d666c58f98 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6393216 Reviewed-by: Kevin Ellis <[email protected]> Commit-Queue: David Awogbemila <[email protected]> Cr-Commit-Position: refs/heads/main@{#1439452}
1 parent edbf7dd commit 3325432

File tree

2 files changed

+71
-13
lines changed

2 files changed

+71
-13
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<link rel="help" href="https://drafts.csswg.org/web-animations-2#animation-trigger">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
</head>
8+
<body>
9+
<style>
10+
.scroller {
11+
overflow-y: scroll;
12+
border: solid 1px;
13+
place-self: center;
14+
height: 300px;
15+
width: 200px;
16+
}
17+
@keyframes slide-in {
18+
from {
19+
transform: translateX(-50px);
20+
}
21+
}
22+
.target {
23+
height: 100px;
24+
width: 100%;
25+
background-color: blue;
26+
animation: slide-in 3s;
27+
animation-trigger: view() alternate contain 0% contain 100%;
28+
}
29+
.target {
30+
height: 100px;
31+
width: 100%;
32+
background-color: blue;
33+
}
34+
.space {
35+
height: 250px;
36+
width: 50%;
37+
}
38+
39+
.active {
40+
animation-fill-mode: both;
41+
}
42+
.idle {
43+
animation-fill-mode: none;
44+
}
45+
46+
</style>
47+
<div id="scroller" class="scroller">
48+
<div class="space"></div>
49+
<div id="subject"></div>
50+
<div class="space"></div>
51+
<div id="active_target" class="active target"></div>
52+
<div id="idle_target" class="idle target"></div>
53+
</div>
54+
<script>
55+
promise_test(async () => {
56+
assert_equals(idle_target.getAnimations().length, 1,
57+
"idle target has an animation");
58+
}, "getAnimations includes an untriggered " +
59+
"'fill-mode: none' animation.");
60+
61+
promise_test(async () => {
62+
assert_equals(active_target.getAnimations().length, 1,
63+
"active target has an animation");
64+
}, "getAnimations does include an untriggered " +
65+
"'fill-mode: both' animation.");
66+
</script>
67+
</body>
68+
</html>

scroll-animations/animation-trigger/animation-trigger.html

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
.target {
2525
animation: myAnim linear 0.5s forwards;
2626
}
27-
.scroll_target {
27+
#scroll_target {
2828
animation-trigger: repeat scroll(inline) 150px 200px 100px 250px;
2929
}
30-
.view_target {
30+
#view_target {
3131
animation-trigger: state view(x) contain 10% contain 90% cover 10% cover 90%;
3232
}
33-
.deferred_target {
33+
#deferred_target {
3434
animation-trigger: alternate --viewtimeline contain 5% contain 80% cover 5% cover 80%;
3535
}
3636
.scroller {
@@ -108,15 +108,7 @@
108108

109109
promise_test(async() => {
110110
await waitForNextFrame();
111-
// Grabbing a reference to the animation and *then* adding the class
112-
// which confers the trigger properties is a workaround to the fact that
113-
// if the scroll-based trigger were already in place, the animation
114-
// would be idle, getAnimations would not include it, and we would not
115-
// be able to get a reference to it.
116-
// TODO: if the definition for getAnimations changes such that it should
117-
// include un-triggered animations, we should remove this workaround.
118111
const animation = scroll_target.getAnimations()[0];
119-
scroll_target.classList.add("scroll_target");
120112
const trigger = animation.trigger;
121113
await waitForNextFrame();
122114

@@ -136,7 +128,6 @@
136128
promise_test(async() => {
137129
await waitForNextFrame();
138130
const animation = view_target.getAnimations()[0];
139-
view_target.classList.add("view_target");
140131
const trigger = animation.trigger;
141132
await waitForNextFrame();
142133

@@ -157,7 +148,6 @@
157148
promise_test(async() => {
158149
await waitForNextFrame();
159150
const animation = deferred_target.getAnimations()[0];
160-
deferred_target.classList.add("deferred_target");
161151
const trigger = animation.trigger;
162152
await waitForNextFrame();
163153

0 commit comments

Comments
 (0)