Skip to content
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

Spec review for Animation.progress #994

Closed
1 task done
DavMila opened this issue Sep 17, 2024 · 7 comments
Closed
1 task done

Spec review for Animation.progress #994

DavMila opened this issue Sep 17, 2024 · 7 comments
Assignees
Labels

Comments

@DavMila
Copy link

DavMila commented Sep 17, 2024

こんにちは TAG-さん!

I'm requesting a TAG review of Animation.progress.

This feature adds a "progress" property to the JavaScript class Animation. The goal of this property is provide authors a convenient and consistent representation of how far along an animation has advanced across its iterations and regardless of the nature of its timeline.

Further details:

@torgo
Copy link
Member

torgo commented Oct 9, 2024

Hi @DavMila - just a quick question: you've indicated "CSS working group" as where this work is being done. However it doesn't seem to be in the CSS repo... is this an official CSS working draft or is it that the intention is to submit it to the CSS working group? Thanks! ✨

@torgo torgo added this to the 2024-10-14-week milestone Oct 9, 2024
@DavMila
Copy link
Author

DavMila commented Oct 11, 2024

Hi @DavMila - just a quick question: you've indicated "CSS working group" as where this work is being done. However it doesn't seem to be in the CSS repo... is this an official CSS working draft or is it that the intention is to submit it to the CSS working group? Thanks! ✨

Thanks for the question. It's in the web-animations-2 spec in the official CSSWG repository for editor's drafts of CSS specifications . I don't think the web-animations-2 spec has been published as a working draft so it's still an editor's draft. So it has been submitted to the CSS working group as part of an editor's draft but not yet a working draft.

@jyasskin
Copy link
Contributor

After a discussion in a breakout:

The explainer doesn't justify this feature well enough. It presents two use cases: one for showing a percentage through a time-based animation, and another for showing a scroll percentage.

The time-based animation has two issues:

  1. It doesn't say why the developer is writing code like this in the first place.
  2. It doesn't show how updateInfo would get called. A big reason to do animations with CSS is to get them off the main thread, but this seems to require interrupting the main thread periodically to change the text.

The scroll percentage code doesn't show the "before" state. What would the code look like if you only used scrollTop and friends to measure progress and draw the meter? Is using animations simpler or more performant here, given the common use cases' needs for animation-range and the named timeline ranges?

It's possible but complicated to render text directly from an animated property: https://dev.to/madsstoumann/clocks-countdowns-timing-in-css-and-javascript-554n. Maybe the use cases for Animation.progress would be better served by making that easier to use?

Finally, if you do need a property for this, it seems confusing to have two .progress properties with different meanings (within-iteration for myAnimation.effect.getComputedTiming().progress vs overall for myAnimation.progress). Please find a different name for the new meaning.

@jyasskin jyasskin added the Progress: pending external feedback The TAG is waiting on response to comments/questions asked by the TAG during the review label Oct 21, 2024
@DavMila
Copy link
Author

DavMila commented Oct 25, 2024

I've updated the explainer to address some of the concerns raised by @jyasskin .

  1. It doesn't say why the developer is writing code like this in the first place.
  2. It doesn't show how updateInfo would get called. A big reason to do animations with CSS is to get them off the main thread, but this seems to require interrupting the main thread periodically to change the text.

The interest in a progress accessor was mainly driven by scroll-driven animations but it does seem to be a concept that would be valid for time-driven animations as well so I've set up a demo showing a more useful scenario: where a dev might want to synchronize audio based on the progress of an animation .

I've also:

  • included a scroll-driven demo where the currentTime of a video is set based on the progress of a scroll-driven animation.
  • included a code example of how scrollTop could instead be used to make the before/after contrast clearer.

About the name of the property, I agree that it could be confusing, maybe a name like totalProgress would work better - I'll file an issue with the CSS working group for this.

Further feedback appreciated :)

@jyasskin jyasskin added Progress: in progress and removed Progress: pending external feedback The TAG is waiting on response to comments/questions asked by the TAG during the review labels Oct 25, 2024
@jyasskin jyasskin added Progress: propose closing we think it should be closed but are waiting on some feedback or consensus and removed Progress: in progress labels Nov 7, 2024
@jyasskin
Copy link
Contributor

@tabatkins, does w3c/csswg-drafts#6245 (comment) affect this review?

@tabatkins
Copy link

No, completely unrelated name clash.

@jyasskin
Copy link
Contributor

Thank you for the fleshed out use cases in the explainer. We agree that it makes sense to be able to pass this value through Javascript to feed it into any parts of the platform that can't be directly animated by CSS.

Thank you also for driving the CSSWG to pick a clearer name. With that done, we don't see any other issues with this proposal, so we'll close this review. Thanks!

@jyasskin jyasskin added Progress: review complete Resolution: satisfied The TAG is satisfied with this design and removed Progress: propose closing we think it should be closed but are waiting on some feedback or consensus labels Nov 14, 2024
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

6 participants