-
Notifications
You must be signed in to change notification settings - Fork 711
[web-animations-1] Define animation replacing behavior #3833
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
Conversation
This still needs work:
I've tried to make the descriptions very general so that they "just work" when we introduce group effects. That's at least partly why some of them are a bit convoluted. (In my experience, the implementation for this is simpler than the spec text.) For now, though, hopefully this is ready enough for feedback. |
… the element is not rendered
I've made all the outstanding changes I had in mind for this PR so it should be ready to review now. |
@graouts @stephenmcgruer @flackr review ping? |
|
||
1. Let |effect value| be the result of calculating the result of | ||
|partialEffectStack| for |property| using |target|'s computed | ||
style (see [[#calculating-the-result-of-an-effect-stack]]). |
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.
Can this still result in growing lists? I.e. if we have composite: 'add' transforms might this result in an ever growing transform list or is the effect value the transform matrix? What about filter lists?
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.
Yes, it can. The computed value for transforms is a list, it just happens to be serialized as a single matrix value. For filters too, there is a similar issue.
|animation|. | ||
The task source for this task is the [=DOM manipulation task | ||
source=]. | ||
|
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.
Should the animation then be removed? Is the replace state change sufficient to imply the animations is removed?
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.
Yes, setting the replace state to removed at the beginning of the procedure is sufficient for it to stop being returned from getAnimations()
and stop contributing to the effect stack.
web-animations-1/Overview.bs
Outdated
: <dfn method for=Animation lt='persist()'>void persist()</dfn> | ||
:: Sets this animation's [=replace state=] to | ||
[=persisted replace state|persisted=]. | ||
: <dfn method for=Animation lt='commitStyles()'>void commitStyles(properties)</dfn> |
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.
Do you expect that only applying some of the animation styles but not all of them will be a common use case? Might it make sense to start with an API where all properties are applied and allow for upgrading in the future?
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.
Yes, I'm not sure. I added this at @graouts' suggestion but I'm fine with leaving it off and adding it later if that's preferable. (And when I implemented it I made this feature a separate patch to prove it could be incrementally added.)
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 think we should start without any arguments and consider adding a list of properties in a future version if we feel it is warranted.
web-animations-1/Overview.bs
Outdated
:: Writes the current [=effect values=] | ||
produced by this animation's [=animation effects=] | ||
to their corresponding [=target elements=]' inline style | ||
using the [=commit computed styles=] procedure |
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.
What's the motivation for adding a commit mechanism over a way to retrieve the animation's effective output? I haven't fully thought through the implications but it seems a simpler API to simply pass a dictionary of values with the replace event.
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 believe the motivation was simply to avoid authors having to add boilerplate code. Unfortunately, passing a dictionary of values has two problems:
-
It doesn't extend easily to
GroupEffect
s. We'd need to add aMap
or something to the event instead, to map from target elements to computed style. -
It requires us to either always flush style in order to produce the correct computed style for the current frame, or never flush style and return potentially out-of-date style (see examples here).
At least always flushing style means we only do it once, regardless of how many animations are being removed in the current frame. Perhaps we could even spec that it only happens if there is at least one
remove
event listener, I'm not sure. Flushing style at that point in the frame might be a bit odd though -- triggering transitions before we runrequestAnimationFrame
callbacks.The advantage of the
commitStyles()
approach is that, even assuming we make it flush style, the author is in charge of calling it so it won't flush styles unless they use it and the side effects are more understandable. The disadvantage is that it means that if several animations are removed in the same frame, then callingcommitStyles()
several times will flush and dirty style multiple times.
Having a means to get the computed style of an Animation
/ AnimationEffect
is nice because it might be more generally useful but it doesn't really help avoid the boilerplate @graouts was concerned about.
I'm a little unclear what the state of a removed animation is, i.e. can it be replayed? retargeted? Does it's replace state change if it is? |
The replace state is part of the animation model so it's entirely orthogonal to any timing. All it means is that:
So:
I have a few tests (1, 2, 3) for these things that may or may not be useful in understanding the behavior. |
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 to me overall, many thanks to you @birtles for all the work putting this together. I look forward to implementing this and possibly providing finer details at that stage.
I've dropped the |
This fixes #3689.