-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDA: Fix start time calculation when changing timelines.
We don't necessarily know the correct start time when changing timelines. Thus, if the animation is already running, we should fall back to using a deferred start time similar to when playing an animation attached to a scroll timeline. While fixing this issue, it became apparent that there was an error in how we normalized time based animations. The full timeline duration is used even if the animation range aligns with only a portion of the timeline. This bug does not manifest if using duration auto, but does appear if using an explicit duration. (cherry picked from commit 2b175a5) Bug: 1450710 Change-Id: I82ea3279af1ecaaa914614d6f07460511634d8a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4582749 Commit-Queue: Kevin Ellis <kevers@chromium.org> Reviewed-by: Robert Flack <flackr@chromium.org> Cr-Original-Commit-Position: refs/heads/main@{#1152602} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4608623 Cr-Commit-Position: refs/branch-heads/5790@{#687} Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
- Loading branch information
1 parent
0e1f7d9
commit 7a222ed
Showing
6 changed files
with
188 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
78 changes: 78 additions & 0 deletions
78
...ternal/wpt/scroll-animations/scroll-timelines/intrinsic-iteration-duration.tentative.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>Scroll based animation: AnimationEffect.getComputedTiming</title> | ||
<link rel="help" href="https://www.w3.org/TR/web-animations-2/#dom-animationeffect-getcomputedtiming"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/web-animations/testcommon.js"></script> | ||
<script src="testcommon.js"></script> | ||
<style> | ||
.scroller { | ||
overflow: auto; | ||
height: 100px; | ||
width: 100px; | ||
will-change: transform; | ||
} | ||
.contents { | ||
height: 1000px; | ||
width: 100%; | ||
} | ||
</style> | ||
<body> | ||
<div id="log"></div> | ||
<script type="text/javascript"> | ||
|
||
//------------------------------------ | ||
// Time-based duration | ||
//------------------------------------ | ||
|
||
test(t => { | ||
const anim = createScrollLinkedAnimationWithTiming(t, {duration: 1000 }); | ||
assert_equals(anim.effect.getTiming().duration, 1000); | ||
assert_percents_equal(anim.effect.getComputedTiming().duration, 100); | ||
}, 'Computed duration in percent even when specified in ms'); | ||
|
||
test(t => { | ||
const anim = createScrollLinkedAnimationWithTiming(t, { duration: 1000 }); | ||
anim.rangeStart = { offset: CSS.percent(20) }; | ||
anim.rangeEnd = { offset: CSS.percent(80) }; | ||
assert_equals(anim.effect.getTiming().duration, 1000); | ||
assert_percents_equal(anim.effect.getComputedTiming().duration, 60); | ||
}, 'Time-based duration normalized to fill animation range.'); | ||
|
||
test(t => { | ||
const anim = | ||
createScrollLinkedAnimationWithTiming( | ||
t, {duration: 700, delay: 100, endDelay: 200 }); | ||
assert_equals(anim.effect.getTiming().duration, 700); | ||
assert_percents_equal(anim.effect.getComputedTiming().duration, 70); | ||
}, 'Time-based duration normalized to preserve proportional delays.'); | ||
|
||
//------------------------------------------------- | ||
// Duration 'auto' = Intrinsic iteration duration | ||
//------------------------------------------------- | ||
|
||
test(t => { | ||
const anim = createScrollLinkedAnimationWithTiming(t, {}); | ||
assert_equals(anim.effect.getTiming().duration, 'auto'); | ||
assert_percents_equal(anim.effect.getComputedTiming().duration, 100); | ||
}, 'Intrinsic iteration duration fills timeline.'); | ||
|
||
test(t => { | ||
const anim = createScrollLinkedAnimationWithTiming(t, {}); | ||
anim.rangeStart = { offset: CSS.percent(30) }; | ||
anim.rangeEnd = { offset: CSS.percent(90) }; | ||
assert_equals(anim.effect.getTiming().duration, 'auto'); | ||
assert_percents_equal(anim.effect.getComputedTiming().duration, 60); | ||
}, 'Intrinsic iteration duration accounts for animation range.'); | ||
|
||
test(t => { | ||
const anim = | ||
createScrollLinkedAnimationWithTiming( | ||
t, { iterations: 4 }); | ||
assert_equals(anim.effect.getTiming().duration, 'auto'); | ||
assert_percents_equal(anim.effect.getComputedTiming().duration, 25); | ||
}, 'Intrinsic iteration duration accounts for number of iterations'); | ||
|
||
</script> | ||
</body> |
This file contains 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
This file contains 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