Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/web-animations/testcommon.js"></script>
<script src="/dom/events/scrolling/scroll_support.js"></script>
<script src="support/support.js"></script>
<script src="support/trigger-scope-support.js"></script>
</head>
<body>
<style>
@keyframes expand {
from { transform: scaleX(1) }
to { transform: scaleX(2) }
}
#outerscroller {
position: relative;
overflow-y: scroll;
border: solid 1px;
height: 400px;
width: 400px;
}
#innerscroller {
overflow-y: scroll;
height: 200px;
width: 200px;
border: solid 1px;
trigger-scope: all;
display: block;
}
#source {
position: absolute;
top: 100%;
height: 100px;
width: 100px;
background-color: blue;
timeline-trigger: --trigger view() contain;
}
.target {
background-color: red;
height: 100px;
width: 100px;
animation: expand linear 1s both;
animation-trigger: --trigger play-forwards play-backwards;
}
#in_scope_target {
/* Let's it be in view when the trigger source comes into view */
margin-top: 50%;
}
#in_scope_oof_target {
position: fixed;
left: 50vw;
}
#out_of_scope_oof_target {
position: fixed;
left: 50vw;
top: 50vh;
}
.long {
width: 50%;
height: 100%;
}
</style>
<div id="outerscroller">
<div id="innerscroller">
<div id="in_scope_target" class="target">In-scope In-Flow Target</div>
<div id="in_scope_oof_target" class="target">In-scope OOF Target</div>
<div class="long"></div>
<div class="long"></div>
<div id="source">SOURCE</div>
<div class="long"></div>
<div class="long"></div>
</div>
<div id="out_of_scope_target" class="target">
Out-of-scope In-Flow False Target
</div>
<div id="out_of_scope_oof_target" class="target">
Out-of-scope OOF False Target
</div>
<div class="long"></div>
<div class="long"></div>
</div>
<script>
const in_scope_targets = [in_scope_target, in_scope_oof_target];
const out_of_scope_targets =
[out_of_scope_target, out_of_scope_oof_target];
promise_test(async() => {
for (const target of in_scope_targets) {
assert_equals( target.getAnimations().length, 1);
await assert_playstate_and_current_time(target.id,
target.getAnimations()[0],
"paused");
}
// The out-of-scope targets should be attached to the trigger and paused
// are yet to be paused by the trigger.
for (const target of out_of_scope_targets) {
assert_equals( target.getAnimations().length, 1);
await assert_playstate_and_current_time(target.id,
target.getAnimations()[0],
"paused");
}
// Perform a scroll to trigger the animation.
const scrollend_promise =
waitForScrollEndFallbackToDelayWithoutScrollEvent(outerscroller);
source.scrollIntoView({block: "center"});
await scrollend_promise;
await waitForCompositorReady();
assert_greater_than(outerscroller.scrollTop, 0, "did scroll");
// The in-scope targets should now be playing as the trigger condition
// has been met.
for (const target of in_scope_targets) {
assert_equals( target.getAnimations().length, 1);
await assert_playstate_and_current_time(target.id,
target.getAnimations()[0],
"running");
}
// There should be no change to the out-of-scope targets.
for (const target of out_of_scope_targets) {
assert_equals( target.getAnimations().length, 1);
await assert_playstate_and_current_time(target.id,
target.getAnimations()[0],
"paused");
}
}, "In-scope targets find trigger of oof source; out-of-scope " +
"targets do not.");
</script>
</body>
</html>