Skip to content

Instantly share code, notes, and snippets.

@jgable
Created June 21, 2011 22:33
Show Gist options
  • Save jgable/1039106 to your computer and use it in GitHub Desktop.
Save jgable/1039106 to your computer and use it in GitHub Desktop.
Page Transition Content Animation Example
opts.transitionHandler = function(name, $to, $from, cb) {
$from.hide(name, {direction: 'left', easing: 'easeOutQuad'}, 350, function() {
// Transition in the to element
opts.getContentHolder().append($to);
$to.show(name, {direction: 'right', easing: 'easeOutQuad'}, 350, function() {
// Remove the from element
$from.detach();
if($.isFunction(cb)) { cb(); }
});
});
};
// If we support css transitions, set our alternate transition handler.
if(Modernizr.csstransitions) {
//animation complete callback
$.fn.animationComplete = function( callback ) {
if( Modernizr.csstransitions ) {
return $( this ).one( 'webkitAnimationEnd', callback );
}
else{
// defer execution for consistency between webkit/non webkit
setTimeout( callback, 0 );
return $( this );
}
};
opts.transitionHandler = function(name, $to, $from, cb) {
$from.addClass('slide out');
$from.animationComplete(function() {
$from.detach();
opts.getContentHolder().append($to);
$to.addClass('slide in');
});
$to.animationComplete( function() {
if($.isFunction(cb)) { cb(); }
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment