Skip to content

Commit

Permalink
Fix current time for inactive timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesodland committed Feb 2, 2024
1 parent 4752cac commit e8a47f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/proxy-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,11 @@ function autoAlignStartTime(details) {
// 5. Let start offset be the resolved timeline time corresponding to the start of the animation attachment range.
// In the case of view timelines, it requires a calculation based on the proportion of the cover range.
try {
startOffset = CSS.percent(fractionalStartDelay(details) * 100);
const startDelayFraction = fractionalStartDelay(details);
if (startDelayFraction === null)
return;

startOffset = CSS.percent(startDelayFraction * 100);
} catch {
// TODO: Validate supported values for range start, to avoid exceptions when resolving the values.

Expand All @@ -901,7 +905,11 @@ function autoAlignStartTime(details) {
// 6. Let end offset be the resolved timeline time corresponding to the end of the animation attachment range.
// In the case of view timelines, it requires a calculation based on the proportion of the cover range.
try {
endOffset = CSS.percent((1 - fractionalEndDelay(details)) * 100);
const endDelayFraction = fractionalEndDelay(details);
if (endDelayFraction === null)
return;

endOffset = CSS.percent((1 - endDelayFraction) * 100);
} catch {
// TODO: Validate supported values for range end, to avoid exceptions when resolving the values.

Expand Down
5 changes: 4 additions & 1 deletion src/scroll-timeline-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ export function range(timeline, phase) {
if (!(timeline instanceof ViewTimeline))
return unresolved;

if (!sourceMeasurements || !subjectMeasurements)
return unresolved;

return calculateRange(phase, sourceMeasurements, subjectMeasurements, details.axis, details.inset);
}

Expand Down Expand Up @@ -810,7 +813,7 @@ export function fractionalOffset(timeline, value) {

export function calculateRelativePosition(phaseRange, offset, coverRange, subject) {
if (!phaseRange || !coverRange)
return 0;
return null;

let style = getComputedStyle(subject)
const info = {
Expand Down

0 comments on commit e8a47f8

Please sign in to comment.