HTML5 Zone is brought to you in partnership with:

John regularly blogs about ColdFusion, JavaScript and other web technologies and contributes to several FOSS projects. His hobbies include writing in the third person. John is a DZone MVB and is not an employee of DZone and has posted 32 posts at DZone. You can read more from them at their website. View Full User Profile

ColdFusion ORM Book Experimenting with CSS3 transition callbacks

01.26.2013
| 1267 views |
  • submit to reddit

I was discussing with my colleague Andy Beer about replacing some jQuery animation with CSS3 transitions so that we could make use of hardware acceleration. This lead me to start thinking about how you'd handle callbacks if you wanted to chain together animations as CSS doesn't have events.

I found some information over on the Mozilla Developer Network site showing that you can add event listeners to DOM elements using JavaScript which will fire when the transitions completes. Unfortunately Webkit and Firefox use a different eventname and IE10 doesn't seem to work at all even though the docs say it should.

Here's a fiddle of what I've got.

There are a couple of things to note here; firstly that FireFox uses the 'transitionend' event name (and IE is supposed to as well) and WebKit based based browsers use webkitTransitionEnd. The other thing, which I hadn't expected was that the event fires twice - once for the end of the left transition, and again once the top transition ends. If you ran the fiddle you will have noticed that I've logged the property name of the completed transition by calling e.propertyName. 

So, if you wanted to fire another animation, you could do so from the transitionEnd function. However as it's not widely adopted, I can't see myself using this in production just yet.

Published at DZone with permission of John Whish, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)