Re: [animations] fill modes, revised

On Mar 2, 2010, at 10:20 am, Tab Atkins Jr. wrote:

> On Tue, Mar 2, 2010 at 11:49 AM, Simon Fraser <smfr@me.com> wrote:
>> 
>> animation-fill-mode:  none | forwards | backwards | both;
>> 
>> The 'animation-fill-mode' property defines whether the effects of an animation are apparent before the animation starts, and after it ends. It has the effect of logically extending the first keyframe back in time, and/or extending the final keyframe forwards in time.
>> 
>> The default is "none", and the existing behavior.
>> 
>> "backwards" means that the "from" or 0% keyframe will apply before the animation starts (i.e. the time between when the animation style is applied and the beginning of the animation, which might be delayed by "animation-delay").
>> 
>> "forwards" means that the last keyframe that was applied will continue to apply after the final iteration of the animation (until the animation style is removed). The last keyframe to be applied is the 'to' or '100%' keyframe, unless the animation has animation-direction set to 'alternate' and a finite and even iteration count, in which case the 'from', or '0%' keyframe is the one whose rules will be applied for the forwards fill.
>> 
>> "both" means that the animation will extend both back and forward.
>> 
>> Without fill modes, writing purely declarative animations can be a huge pain. You either need to use script, or somehow tweak your keyframes make a huge duration (which is annoying to change if you want to change parameters). It's a very common component of animations and we should have included it from the first proposal.
>> 
>> Simon
>> 
>> [1] http://www.w3.org/TR/SMIL2/smil-timing.html#Timing-fillAttribute
> 
> I like the forwards fill, and agree that it sounds necessary.
> 
> It appears that backwards fill is just a convenience, and could be
> approximated by baking the delay into the first keyframe?  I'm just
> making sure I understand it correctly.

If you only iterate once, that's true. However, if you want the animation to repeat, then you don't have the luxury of extending the first keyframe.

We'd like to keep the behavior of "delay" as it applies to transitions and animations to be similar; in both cases, it postpones the start of the effect some time into the future, so we think the behavior of animation-fill-mode as it relates to animation-delay is appropriate.

Simon

Received on Tuesday, 2 March 2010 18:36:11 UTC