Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /scroll-animations/animation-trigger/trigger-scope-out-of-scope-source.tentative.html - WPT Dashboard Interop Dashboard
<!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%;
}
.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 class="long"></div>
<div class="long"></div>
</div>
<div id="source">SOURCE</div>
<div id="out_of_scope_target" class="target">
Out-of-scope In-Flow False Target
</div>
<div class="long"></div>
<div class="long"></div>
</div>
<script>
promise_test(async() => {
await assert_playstate_and_current_time(
in_scope_target.id, in_scope_target.getAnimations()[0], "paused");
// The out-of-scope target should be attached to the trigger and
// paused at time 0.
await assert_playstate_and_current_time(out_of_scope_target.id,
out_of_scope_target.getAnimations()[0],
"paused");
const scrollend_promise =
waitForScrollEndFallbackToDelayWithoutScrollEvent(outerscroller);
source.scrollIntoView({block: "center"});
await scrollend_promise;
await waitForCompositorReady();
assert_greater_than(outerscroller.scrollTop, 0, "did scroll");
// There should be no change to the in-scope target.
await assert_playstate_and_current_time(in_scope_target.id,
in_scope_target.getAnimations()[0],
"paused");
// The out-of-scope target should now be playing as the trigger
// condition has been met.
await assert_playstate_and_current_time(out_of_scope_target.id,
out_of_scope_target.getAnimations()[0],
"running");
}, "trigger-scope prevents in-scope target from finding trigger " +
"outside scope; target outside trigger-scope finds trigger");
</script>
</body>
</html>