W3C home > Mailing lists > Public > www-style@w3.org > December 2009

Re: [css3-animations] running animations before document load event

From: Simon Fraser <smfr@me.com>
Date: Tue, 22 Dec 2009 09:32:00 -0800
Cc: www-style@w3.org
Message-id: <EC81C7AB-D3E9-461C-9374-84986B8DDA8A@me.com>
To: "L. David Baron" <dbaron@dbaron.org>
On Dec 22, 2009, at 8:51 AM, L. David Baron wrote:

> http://dev.w3.org/csswg/css3-animations/#animation-behavior- says:
>  # The start time of an animation is the latter of two moments: the
>  # time at which the style is resolved that specifies the
>  # animation, or the time the document's load event is fired.
> 
> This seems somewhat problematic to me, since pages often want to be
> usefully interactive before the load event has fired.  (For example,
> the load event could be delayed due to a slow-loading advertisement
> image, or while waiting for the photo in the center of a flickr page
> to load, etc.)
> 
> That said, I see the value in synchronizing animations that are
> specified in the style present when the document loads, so this
> behavior seems like it may be a reasonable default (although perhaps
> DOMContentLoaded would be a better default).

WebKit originally delayed the start of all CSS animation until the page load
event fired, to match the SVG implementation. More recently we changed
it to run animations as soon as we create renderers for the elements
being animated.

> However, I think there ought to be a mechanism for overriding that
> default and allowing animations to start before the document is
> fully loaded.
> 
> I don't have strong opinions about what that mechanism should be,
> other than that it seems like it would have to be an API called from
> script.  However, I can think of a number of questions about that
> API:
> * should it essentially change the document load time as far as
>   animations are concerned, or should it start only animations
>   currently present and leave the rest to start when the load event
>   fires (or on a later call to this API)?
> * should it allow starting only animations on certain elements or
>   element subtrees?
> * should it be possible to restart (on document load, or at another
>   time) the animations that were started by such an API?

Does this need API? If the author wants animations to start as soon
as possible, they just declare them in the style that will apply to
the element as soon as it appears.

If they want animations to start at page load, they simply structure
their CSS to set the animation-name property via some script
that runs in response to the 'load' event (e.g. by setting a class name).

I'd prefer to avoid adding animation-related API at this point.

Simon
Received on Tuesday, 22 December 2009 17:32:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 03:47:12 GMT