Re: [web-animations] Elegant way to clear (nested) animation effect?

I just realize it's probably better if I build a layer on top of web-animations instead of extending it for cases like these.

> On May 4, 2015, at 2:48 PM, Glen Huang <curvedmark@gmail.com> wrote:
> 
> By clearing, I mean a use case like this:
> 
> Before an animation effect's first frame is rendered, a temporary class is added to the target, making it suitable for animation (e.g., absolutely position it), and after the associated animation is finished, the temporary class is cleared (likely also clear forwards fill by mutating the timing property and adding the real class to move the element in place).
> 
> I find this way of doing UI animation having a high fault tolerance (miscalculated dimensions unlikely to cause butterfly effect).
> 
> From level 2 of the spec, it seems animation effect will trigger a "sample" event before the first frame is rendered? If so, it should be an appropriate moment to add the temporary class. Now the problem is, if I remove the temporary class in the "finish" event of the animation, the animation effect is no longer self-contained. It has the knowledge of how to prepare the target, how to apply styles to the target, but even though it should also have the knowledge of how to undo the preparation, I can't code that into it, because there is no event hook in the animation effect for the moment when the associated animation is finished.
> 
> I wonder if it makes sense to fire an event in animation effect for such moment (actually to generalize it, maybe it should fire a event whenever it changes phase)? But this doesn't seem to be enough when group effect is involved. When being nesting inside a group effect, you sometimes don't want to remove the temporary class until the *whole* group effect has finished. In this case it seems it would be great if a event could be fired in the animation effect every time one of its associated ancestor animation is finished, and there is some way to identify the animation you care.
> 
> I'm not sure if the solution I come up with is feasible. Is there more elegant way of doing it?
> 
> Thanks.

Received on Monday, 4 May 2015 09:48:17 UTC