Skip to content

[web-animations-2] procedure to convert a time-based animation to a proportional animation might yield a division by 0 #11276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
graouts opened this issue Nov 26, 2024 · 5 comments
Labels

Comments

@graouts
Copy link
Contributor

graouts commented Nov 26, 2024

The procedure to convert a time-based animation to a proportional animation has the following sub-step:

Let total time be equal to end time

… and then several steps after that where we divide values by total time. However, total time may be 0, for instance if the specified delay is the negative value of the specified iteration duration, as is the case in the WPT test scroll-animations/scroll-timelines/effect-updateTiming.html:

test(t => {
  const anim = createScrollLinkedAnimationWithTiming(t, {duration: 100, delay: -100})
  anim.play();
  anim.effect.updateTiming({ delay: -100 });
  assert_equals(anim.effect.getTiming().delay, -100, 'set delay -100');
  assert_equals(anim.effect.getComputedTiming().delay, -100,
                'getComputedTiming() after set delay -100');
  assert_percents_equal(anim.effect.getComputedTiming().endTime, 0,
                        'getComputedTiming().endTime after set delay -100');
}, 'Allows setting the delay to a negative number');

The spec needs a provision for computing the start delay, end delay and iteration duration in this case.

@graouts graouts added web-animations-2 Current Work scroll-animations-1 Current Work labels Nov 26, 2024
@graouts
Copy link
Contributor Author

graouts commented Nov 26, 2024

Cc @kevers-google, @flackr and @andruud who are the knowledgeable persons in this area.

@graouts
Copy link
Contributor Author

graouts commented Nov 27, 2024

By the looks of it, in that situation, Chrome sets start delay, end delay and iteration duration to 0%, maintaining the end time at 0%.

@flackr
Copy link
Contributor

flackr commented Nov 27, 2024

I think this leads to the most intuitive behavior. An animation with end time = 0 immediately produces its after phase effect once you pass the start time. Maintaining the end time here achieves the same result.

If we tried to force the animation to have some duration it would be unclear how to distribute that duration.

@graouts
Copy link
Contributor Author

graouts commented Nov 27, 2024

We should clarify the spec to have this behavior.

@graouts
Copy link
Contributor Author

graouts commented Nov 28, 2024

For reference, this was discovered while working on WebKit/WebKit#37219.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants