W3C home > Mailing lists > Public > www-style@w3.org > November 2011

[css3-animations][css3-transitions] AnimationEvent and TransitionEvent should have constructors and schew init methods

From: Dominic Cooney <dominicc@chromium.org>
Date: Tue, 8 Nov 2011 10:56:12 -0800
Message-ID: <CAHnmYQ8xbt_O3P6BJ+fb4Nk5EpOp7r7JOz0eQ==vXhcBujPT4A@mail.gmail.com>
To: www-style@w3.org, Sylvain Galineau <sylvaing@microsoft.com>, dbaron@dbaron.org
I note that recent drafts of many specs—DOM4, HTML, Workers, WebSocket,
etc. specify events with constructors that take a dictionary of arguments,
and don’t specify an init*Event method. So instead of this:

var e = document.createEvent('TransitionEvent');
e.initEvent(type, false, true, 'background-color', 0.3);

This:

new TransitionEvent(type, {
    bubbles: false,
    cancelable: true,
    propertyName: 'background-color',
    elapsedTime: 0.3
  });

This is more convenient because it is a single expression and easier to
read because the arguments are effectively labeled by the hash properties.

You could look at the HashChangeEvent as a typical example of how the
constructor and dictionary are described in Web IDL. <
http://dev.w3.org/html5/spec/Overview.html#hashchangeevent>

It would be nice if CSS3 Animations and CSS3 Transitions adopted this style
for events.

Dominic
Received on Tuesday, 8 November 2011 19:02:29 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:46 GMT