-
Notifications
You must be signed in to change notification settings - Fork 689
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-1] Add hold phase to animation #4325 #5479
base: main
Are you sure you want to change the base?
Conversation
Overall, it looks good. Would like input from those more familiar with timeline phase. |
Thanks for doing this. The formatting and everything looks great. I'm just a little concerned that this is quite invasive and increases the essential complexity of the model in the sense that there is now yet another state variable we need to check/update in each procedure. Is there any other possible way of fixing #4325? Perhaps this is the best/only way but I'd like to be sure so if you have any comments about why this is necessary that would be most helpful! (Incidentally, this is the sort of thing I would like to put in level 2 if possible, but I'll wait to hear how others feel about doing that.) |
Thanks for looking at it Brian! I'm finally getting the hang of formatting :) I will try to explain the thoughts behind hold_phase while also providing a potential alternative. First some setup: To accomplish this, we have a function that returns the current phase, similar to existing function that returns current time (https://drafts.csswg.org/web-animations/#the-current-time-of-an-animation). Here is where we can have 2 different implementations of CurrentPhase(): Option 1: Add hold_phase which will hold timeline phase data (same as how hold_time hold timeline time data) and is updated anytime hold_time is updated. They should both always be updated or cleared together. Then we can do this:
Option 2: If we decide adding hold_phase is too much overhead, we could have a simpler, although not as correct, implementation:
This will work as expected as long as the timeline is active and playing, but starts to misbehave when paused or any other situation that causes hold_time to be in use. Take for example a timeline with Now pause the animation. For Option 1: When the animation is paused, hold_phase is set to For Option 2: When the animation is paused, hold_time is set to 0. This causes I suggest we add hold_phase for correctness and because it updates at the same time as hold_time, I think maintainability will be manageable. |
Thanks Jordan! The example really helps. I don't suppose this has any affect on #5423 by the way? I've printed this out and put it on my desk so I'll look at it tomorrow morning. (For my own notes, I believe this will be fine when we come to nested effects since we'll only apply the behavior to the rootmost effect.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good with the suggested changes.
Ideally we want to move this and timeline phase to level 2 but that's going to make for a pretty hard-to-read delta spec I guess.
The current plan is to have this PR moved to level 2, but will do so by waiting for level 1 to get finalized. As I understand it, that will make it much easier than trying to modify this into a delta spec change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good with these comments addressed.
web-animations-1/Overview.bs
Outdated
<a>current time</a>. The <a>hold phase</a> has the same range of values as the | ||
[=timeline phase=] and can be set or unset. The <a>hold phase</a> is initially | ||
unset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit for future reference as much as anything, in specs we try to use semantic line breaking where possible. This makes diffs smaller and easier to read.
There are a few articles about this like:
https://rhodesmill.org/brandon/2012/one-sentence-per-line/
https://ramshankar.org/blog/posts/2019/semantic-line-breaks/
We haven't done this very consistently in this spec so far, but going forward we should try to at least start each sentence on a new line (and preferably also after each comma, clause etc.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to remember that going forward. Thanks!
This PR will be moved to web-animations-2 after web-animations-1 has been merged into web-animations-2. This PR should not be merged while modifications are in web-animations-1. |
… for animation current phase.
…om resolved to unset, fixed some formatting errors
…ion is in idle state
01c13cc
to
fad6e37
Compare
260f194
to
1ca8964
Compare
I have moved all the changes over to Web-Animations-2. Please take a look and make sure I did this the right way. First time moving from one level to another :) |
Hi Jordan, thanks for doing this. I'm afraid I haven't looked through the whole patch, but just looking at the start it seems to be duplicating the text from level 1? I believe the idea was to keep the level 2 spec a delta spec until level 1 is stabilized? That is, it should be more like a diff? I think the existing text does that be saying things like "This paragraph is added", "This sentence is changed" etc. Is it possible to do the same for this patch? That way if we update the duplicated text in level 1 we will be sure to pick up those changes in level 2 later. |
Add hold phase to an animation (issue #4325). This PR is an update on #5479, which converts the PR to a delta spec change. The PR introduces addtional factors when calculating the phase of an animation effect. When using a monotonic timeline, the boundaries for the before and after phase can be determined based on the start delay, end time and active duration. The phase of a scroll timeline linked animation needs to factor in scroll offsets. This requirement is achieved by introducing the "current phase" of an animation, which in turn depends on the hold phase when the animation is paused.
[web-animations-1] Add hold phase to animation #4325
Added the concept of
hold phase
to animations. This will allow them to pass the correct phase to associated effects under such conditions as pausing or any other time the existinghold time
is used.Added conditions to the animation effect phase calculation to account for animation current phase.