Playing a transition from jQuery Mobile on a standard page is pretty simple. Start by creating an absolutely positioned container with two relatively spaced children, which will be the two pages you view between them. After you load both pages, apply the "flip" and "out" classes to the page to be replaced and name hide()it. Finally, add the "flip" and "in" classes to the displayed page and call show()on it.
Transitions are just CSS3 transforms, so keep in mind that they wonβt work in all browsers, and they can behave badly on large screens / low-performance machines.
HTML
<button type="button" id="go">FLIP</button>
<div class="container">
<div class="page1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<div class="page2">
Duis interdum, odio vel condimentum varius, nibh nunc ultrices velit.
</div>
</div>
CSS
.container {
position: absolute;
-webkit-perspective: 1000;
-moz-perspective: 1000;
}
.page1 {
width: 300px;
height: 300px;
background: red;
position: relative;
}
.page2 {
width: 300px;
height: 300px;
background: blue;
position: relative;
display: none;
}
.flip {
-webkit-backface-visibility:hidden;
-webkit-transform:translateX(0);
-moz-backface-visibility:hidden;
-moz-transform:translateX(0);
}
.flip.out {
-webkit-transform: rotateY(-90deg) scale(.9);
-webkit-animation-name: flipouttoleft;
-webkit-animation-duration: 175ms;
-moz-transform: rotateY(-90deg) scale(.9);
-moz-animation-name: flipouttoleft;
-moz-animation-duration: 175ms;
}
.flip.in {
-webkit-animation-name: flipintoright;
-webkit-animation-duration: 225ms;
-moz-animation-name: flipintoright;
-moz-animation-duration: 225ms;
}
.flip.out.reverse {
-webkit-transform: rotateY(90deg) scale(.9);
-webkit-animation-name: flipouttoright;
-moz-transform: rotateY(90deg) scale(.9);
-moz-animation-name: flipouttoright;
}
.flip.in.reverse {
-webkit-animation-name: flipintoleft;
-moz-animation-name: flipintoleft;
}
@-webkit-keyframes flipouttoleft {
from { -webkit-transform: rotateY(0); }
to { -webkit-transform: rotateY(-90deg) scale(.9); }
}
@-moz-keyframes flipouttoleft {
from { -moz-transform: rotateY(0); }
to { -moz-transform: rotateY(-90deg) scale(.9); }
}
@-webkit-keyframes flipouttoright {
from { -webkit-transform: rotateY(0) ; }
to { -webkit-transform: rotateY(90deg) scale(.9); }
}
@-moz-keyframes flipouttoright {
from { -moz-transform: rotateY(0); }
to { -moz-transform: rotateY(90deg) scale(.9); }
}
@-webkit-keyframes flipintoleft {
from { -webkit-transform: rotateY(-90deg) scale(.9); }
to { -webkit-transform: rotateY(0); }
}
@-moz-keyframes flipintoleft {
from { -moz-transform: rotateY(-90deg) scale(.9); }
to { -moz-transform: rotateY(0); }
}
@-webkit-keyframes flipintoright {
from { -webkit-transform: rotateY(90deg) scale(.9); }
to { -webkit-transform: rotateY(0); }
}
@-moz-keyframes flipintoright {
from { -moz-transform: rotateY(90deg) scale(.9); }
to { -moz-transform: rotateY(0); }
}
Javascript
You will need to replace this part with something more important for your page, but the concept will be the same.
$('#go').click(function() {
var page1 = $('.page1');
var page2 = $('.page2');
var toHide = page1.is(':visible') ? page1 : page2 ;
var toShow = page2.is(':visible') ? page1 : page2 ;
toHide.removeClass('flip in').addClass('flip out').hide();
toShow.removeClass('flip out').addClass('flip in').show();
});
: http://jsfiddle.net/lakario/VPjX9/