-
Notifications
You must be signed in to change notification settings - Fork 673
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
[web-animations-2] Progress APIs #8799
Comments
Overall it seems reasonable to me. I think defining it in terms of
Mathematically, should it be zero? Not sure if that would be the most useful result, however.
I'd suggest making it readonly. As you pointed out, there are some cases where this value would be We already have enough ways of changing the animation position (setting |
Yeah, mathematically it would be 0. I don't have a strong preference for it to be null/undefined, just thought it might be marginally more meaningful than 0 to distinguish from the case of a 0 that can make progress. |
In favor of this general approach as described here, to tackle #8669. Fine with making it readonly as a starting point. |
Thanks @bramus. Adding to agenda to discuss/resolve:
|
Regarding 1. +1 on adding, with 2 suggestions:
|
The CSS Working Group just discussed
The full IRC log of that discussion<faceless> present-<bramus> flackr: So WAAPI is very focused on absolute times, but with scroll-driven aninamations, developers often just work with progress instead of time <bramus> flackr: seems like a reasonable thing to add, so there is a proposal to get the current progress which is a calcuation between start and and end time <bramus> flackr: also need to specify what hsould happen for infinitely repeating animations <bramus> flackr: Proposal is adding currentProgress to Animation <bramus> flackr: it is calculated as currentTime / effect endTime <bramus> flackr: propose to make it readonly for now <bramus> s/repeating/duration/ <bramus> Rossen_: Any feedback? <ydaniv> I proposed "progress" instead of "currentProgress" <TabAtkins> +1 <TabAtkins> (to the current proposal, no opinion on naming) <bramus> Rossen_: You are taking into account the feedback from ydaniv? <bramus> flackr: Yes, he proposed currentProgress instead of progress <bramus> flackr: dont object to this shorter name and computedTIming value from the effect is also called progress <bramus> Rossen_: what about read/write vs readonly? <bramus> flackr: then have to decide how to handle infinite duration animation <bramus> Rossen_: starting with readonly gives up path to go forward later <bramus> Rossen_: Should we formulate as readonly? not hearing objections from yehonathan <bramus> flackr: would be happy with that <bramus> bramus: me too <bramus> Rossen_: objections to adding as readonly? <bramus> Rossen_: Not hearing anything <bramus> bramus: and the name? <bramus> flackr: we said progress <bramus> flackr: Proposed resolution: add progress to Animation and make it readonly <bramus> RESOLVED: Add progress to Animation and make it readonly |
On the PR from @DavMila there is one point where we don't have a clear answer. Should the progress be clamped to [0, 1]. For the full discussion you can view the PR review #9937 (comment) however I'll do my best to summarize the pros and cons of each.
Ultimately, I think either works, but which is better comes back to how authors will use this. @bramus @fantasai @birtles any thoughts? |
I'm leaning towards 2, since this will probably be used to sync a scroll/view timeline with another effect that can't be done with CSS, e.g.: canvas, SVG, video. So, I think that as default behavior, having this perform as a sort of "manual" CustomEffect, with a clamped progress like KeyframeEffect's is a good way to start, and we could add a new property in the future, like you said, to reflect the more complex cases. |
I agree that 2 makes most sense. I also think, as per the current PR, we shouldn't try to reflect the fill mode of the associated effect. |
However, if we consider the above use-cases, having enter/exit events on the animations, similar requested by @bramus on #7962 may become quite crucial for easily creating such effects without extra IntersectionObserver or |
We could also resolve on adding start/end events on elements as per #9011 which should also help there |
I'll agenda+ this issue so we can get a formal resolution on the question on whether to clamp to [0,1]. |
Perhaps we should extract the idea of checking/specifying an effect in a before/after state? |
If it helps, I can add an example from a research we started on doing exactly what I mentioned above:
Here: https://codepen.io/ydaniv/pen/VwNraKB - trying to scrub a |
The CSS Working Group just discussed
The full IRC log of that discussion<fserb> github-bot take up https://github.com//issues/8799<fantasai> astearns: remaining question is whether we are clamping <fantasai> flackr: we decided to add a progress accessor to animations <fantasai> flackr: question was what to do outside the range of the animation <fantasai> flackr: before animation starts or after it ends <fantasai> flackr: I believe everyone is agreed that clamping is what makes sense, so want to resolve on it <fantasai> flackr: [0%, 100%] <fantasai> flackr: maps to the keyframe you're showing, assuming animation is in effect <fantasai> astearns: any disagreement? <fantasai> RESOLVED: Clamp progress to [0,1] |
Got some feedback that having |
Perhaps |
I like Rob’s suggestion |
I don't know, IMHO, |
The concern isn't that I'm not sure that |
The CSS Working Group just discussed
The full IRC log of that discussion<TabAtkins> DavidA: we added a property field, it reflects the progress of the animation in a way that reflects the iterations of the animation<TabAtkins> DavidA: there is a .progress that exists in AnimationEffect that has a .getComputedTiming() function <TabAtkins> DavidA: but that only reflects the progress of the current animation <TabAtkins> DavidA: got some feedback that it coudl be confusing to share the name since they mean different things <TabAtkins> DavidA: wanted to consider renaming the Animation progress field either totalProgress or currentProgress <TabAtkins> DavidA: not sure which is better to go with <TabAtkins> DavidA: currentProgress is related to currentTime <TabAtkins> DavidA: but totalProgress more strongly reflects taht it covers all the iterations <TabAtkins> fantasai: okay so it's a .progress on AnimationEffect... <TabAtkins> DavidA: no, on Animation itself <TabAtkins> fantasai: is there one on AnimationEffect? <TabAtkins> DavidA: indirectly, kinda <DavidA> AnimationEffect.getComputedTiming().progress <TabAtkins> vmpstr: yehonatan also said he thinks progress if fine and he'd find currentProgress confusing <dholbert> https://www.w3.org/TR/web-animations-1/#calculating-the-overall-progress <TabAtkins> dholbert: WebAnim 1 uses overallProgress <TabAtkins> dholbert: it differentiates that from "simple" iteration progress <fantasai> https://drafts.csswg.org/web-animations-1/#dictdef-computedeffecttiming <TabAtkins> astearns: "overall" is just a name in the algo, not part of the exposed API? <TabAtkins> dholbert: yeah <fantasai> .endTie <fantasai> .endTime <fantasai> .activeDuration <fantasai> .localTime <fantasai> .progress <TabAtkins> fantasai: so this is on an object called ComputedEffectTiming, which has... <fantasai> .currentIteration <TabAtkins> fantasai: and we're suggesting renaming .progress <TabAtkins> fantasai: we currently have .activeDuration, .localTime, .currentIteration <TabAtkins> DavidA: Oh, not the progress field on this object <TabAtkins> DavidA: The one on the Animation class <astearns> I kind of like `overallProgress` <TabAtkins> yeah i'm kinda leaning toward overall <fantasai> https://drafts.csswg.org/web-animations-1/#the-animation-interface <TabAtkins> DavidA: .progress on ComputedEffectTiming has existed for a while, changing woudl be hard <astearns> s/ComputedEffectTiming/getComputedTiming/ <TabAtkins> fantasai: can you string multiple Animations together? <TabAtkins> DavidA: I'm not sure... <TabAtkins> dholbert: i'm slightly uneasy about "total" because it sounds like a summation <TabAtkins> +1 <fantasai> +1 <TabAtkins> astearns: I'd expect "total progress" to not change over time <TabAtkins> DavidA: okay so overallProgress is still something we could consider, or currentProgress <TabAtkins> fantasai: since timingeffect has currentTime and progress, what's the problem with just using progress on this? <fantasai> s/currentTime/localTime/ <TabAtkins> fantasai: you'd get the context off of which object you're getting from <astearns> request for something other than `progress`: https://github.com/w3ctag/design-reviews/issues/994#issuecomment-2427287323 <TabAtkins> astearns: [summarizes Jeffrey's comment] <fantasai> TabAtkins: effect timing can run an animation multipel times, and progress gives you progress of the iteration <fantasai> TabAtkins: this is a 0-1 and done thing, so it's a different concept than what the effect timing one is <fantasai> TabAtkins: can't change that one, but maybe use a different word here <TabAtkins> fantasai: i don't mind overall progress, i'm just saying we both have startTimes, they mean different things <fantasai> fantasai: can tell from context <fantasai> TabAtkins: progress has a different interpretation, because [missed] <fantasai> TabAtkins: AnimationEffect has a .endTime <fantasai> TabAtkins: Effect timing and animation have same interpretation of those <dbaron> (last 2 lines were answering vmpstr asking about whether startTime has the same meaning on both) <fantasai> TabAtkins: Animation has a .startTime and no .endTime / AnimationEffect has .endTime and no .startTime <fantasai> vmpstr: Progress, one cycles per iteration, so wouldn't be the same value at any particular point <fantasai> TabAtkins: for progress, right <fantasai> vmpstr: but if startTime and endTime both existed on the same object, they would be the same, right? <fantasai> TabAtkins: AFAICT from a quick read, they refer to the same type of concept <fantasai> TabAtkins: it's beginning of whole thing it's doing, vs iteratin <fantasai> astearns: gist I'm getting, is ppl think there's enough difference to have a different name <TabAtkins> fantasai: i'm okay with overallProgress <TabAtkins> astearns: so proposed resolution is we change Animation.progress to Animation.overallProgress <TabAtkins> RESOLVED: change Animation.progress to Animation.overallProgress |
In line with the CSS working group's resolution[1] to change Animation.progress to Animation.overallProgress, this patch updates the relevant portions of the web-animations-2 spec. [1] w3c#8799 (comment)
Can we add these APIs to CSS? |
Do you mean to the |
In line with the CSS working group's resolution[1] to change Animation.progress to Animation.overallProgress, this patch updates the relevant portions of the web-animations-2 spec. [1] #8799 (comment) Co-authored-by: David Awogbemila <[email protected]>
I'm making the required WPT change also in web-platform-tests/wpt#49353. |
In line with the CSS working group resolution in #8799[1], this patch renames Animation.progress in to Animation.overallProgress in Blink. [1] w3c/csswg-drafts#8799 (comment) Bug: 40914396 Change-Id: Ie7605f59d99314158b77e9672dbe98a564d2d1e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6049834 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Robert Flack <[email protected]> Cr-Commit-Position: refs/heads/main@{#1387916}
In line with the CSS working group resolution in web-platform-tests#8799[1], this patch renames Animation.progress in to Animation.overallProgress in Blink. [1] w3c/csswg-drafts#8799 (comment) Bug: 40914396 Change-Id: Ie7605f59d99314158b77e9672dbe98a564d2d1e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6049834 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Robert Flack <[email protected]> Cr-Commit-Position: refs/heads/main@{#1387916}
In line with the CSS working group resolution in #8799[1], this patch renames Animation.progress in to Animation.overallProgress in Blink. [1] w3c/csswg-drafts#8799 (comment) Bug: 40914396 Change-Id: Ie7605f59d99314158b77e9672dbe98a564d2d1e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6049834 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Robert Flack <[email protected]> Cr-Commit-Position: refs/heads/main@{#1387916}
…verallProgress, a=testonly Automatic update from web-platform-tests Rename Animation.progress to Animation.overallProgress In line with the CSS working group resolution in #8799[1], this patch renames Animation.progress in to Animation.overallProgress in Blink. [1] w3c/csswg-drafts#8799 (comment) Bug: 40914396 Change-Id: Ie7605f59d99314158b77e9672dbe98a564d2d1e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6049834 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Robert Flack <[email protected]> Cr-Commit-Position: refs/heads/main@{#1387916} -- wpt-commits: 9c416ba6fc2a085fde55600a0056ac30304a8f1f wpt-pr: 49385
In #8669, #8765 and #8201 there seems to be a common desire to have more convenient APIs for getting some representation of progress. Currently you can get the progress of the current iteration of an effect using the getComputedTiming() API as follows:
You can also get the overall effect progress by doing a calculation such as:
However, with several of the other linked issues it seems that it would be convenient for developers to have some form of access to the progress through the attached animation range, or to get that progress directly from the timeline.
We could add a convenience currentProgress helper alongside the currentTime API on Animation:
This could return the progress of currentTime through the entire range before which it is considered complete, e.g. calculated as follows:
currentProgress = currentTime / effect endTime
Note that endTime is infinite when either iterations or duration is infinite. In these cases currentProgress should probably be null or undefined?
Open question - should it be read only or should we allow setting the progress which would be equivalent to setting currentTime to currentProgress * endTime?
As per discussion on #8669 a progress reported on animation should be mostly independent of the effect timing, so we calculate it as the progress from startTime to the time when the animation would resolve its finished promise. This would intentionally not match the progress through the developer specified keyframes.
@birtles @bramus @fantasai
I also propose that given the uncertainty around what's expected from the
getCurrentTime
API on timeline, that we remove it until we have a better understanding of the specific use cases that developers need it for. Perhaps the animation progress API above will address some of them where it seems developers were trying to work this out through the timeline.The text was updated successfully, but these errors were encountered: