//Old Way
$('.le-animate').animate({
width: 300px,
height: 400px,
opacity: 1
}, 3000);
//New Way
.le-animate {
width: 0px; height: 0px; opacity: 0;
-webkit-transition: all 3s ease-in;
-moz-transition: all 3s ease-in;
-ms-transition: all 3s ease-in;
transition: all 3s ease-in;
}
.le-animate.anim {
width: 300px; height: 400px; opacity: 1;
}
$('.le-animate').addClass('anim');
For more complex animations, just use canvas, right? It's supported everywhere

@media only screen and (orientation: portrait) @media only screen and (orientation: landsacpe)
window.onorientationchange = function() {
var orientation = window.orientation; // orientation in degrees
switch(orientation) {
case 0: //iOS portrait
...
break;
case 90: //iOS landscape
...
break;
case -90:
...
break;
}
}
window.onorientationchange = function() {
var mql = window.matchMedia("(orientation: portrait)");
if(mql.matches) {
// do portrait stuff
} else {
// do landscape stuff
}
}
var mql = window.matchMedia("(orientation: portrait)");
mql.addEventListener(function(m) {
if(m.matches) {
// do portrait stuff
} else {
// do landscape stuff
}
})
Drawback: Is not implemented on all systems (iOS4, Android 2.3)
So in worst case, you have to rely on UA sniffing (urks) or some dirty, dirty tricks
First rule: Don't think the support is wide-spread or stable, even if those lists out there say so
Be aware that you can only play one sound at a time, so if you want to have BG music and effects, forget it
iOS devices (and most mobile webkit browsers, like Android) only allow playing sound directly after a user interaction. So
But, the iOS JS engine allows API calls if a user interaction happened, or if the file already has been downloaded completely
<audio src="sprite.mp3" controls="none" id="myaudio" />
var maudio = document.getElementById('myaudio');
var soundSprite = [
{start: 0, end: 3000},
{start: 3500, end: 6789}
];
element.addEventListener('touchstart', function(event) {
maudio.play();
playSoundFile(0);
})
function playSoundFile(idx) {
maudio.currentPosition = soundSprite[idx].start;
var x = setInterval(function() {
if(maudio.currentPosition >= soundSprite[idx].end) {
maudio.pause(); // There is no stop() in HTML5
clearInterval(x);
}
}, 50);
}
Libs like SoundManager2 are great for exactly this task
@ddprrt | http://github.com/ddprrt
stefan.baumgartner@netural.com