It started with Brian King setting up our Google+ page using this round MDN logo by John Slater. I thought this looks cool and reminded me of the famous MGM intro so I wondered if I could turn it into an intro for our video tutorials (not sure if we will do that though). And, some photoshop and sound work later and with a sprinkle of HTML5 audio and CSS transitions, here we are (source on GitHub):
I started with the sound. If you need Creative Commons licensed sounds, Freesound is a good resource. So I took Chinese Fanfare by Nick-Nack and Roar by CGEffex and put them together in Audacity.
Saving them as OGG and MP3 gave me an audio element that I could tie into. All I needed was to listen to the timeupdate
event and compare the currentTime
to trigger the animations. The animations (rotation of the dino and opening and closing of the jaw) are CSS transitions triggered by classes on the parent element. The main trick was to store both the dino and the jaw inside a div and transition them separately. The jaw animation also needed a change in transformation origin as we don’t rotate the image around its center.
If you got seven minutes to spare, here is a blow-by-blow screencast explaining what is going on:
View full post on Mozilla Hacks – the Web developer blog
Very cool. But as you state – you still use JS to make sure the syncing happens when all the things have loaded, so in essence this is the same. I used transitions as they are better supported across browsers. But nothing stops you from achieving this with animations.
And this [1] is the proof.
[1]: https://dl.dropbox.com/u/18835355/html/animation_syncing/anim.html
That’s fantastic.
You don’t have to use JavaScript, you could also use CSS animations.
I’m a little saddened by this, still needing javascript for synching at all almost 7 years after one of my very first comments on bugzilla was hopeful about SMIL on the audio tag:
https://bugzilla.mozilla.org/show_bug.cgi?id=216462#c6
Is it too late to still hope for that?