diff --git a/Makefile b/Makefile index af43acc5..cb03230e 100755 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ JSFILES = js/jquery.ui.widget.js \ js/jquery.mobile.page.js \ js/jquery.mobile.core.js \ js/jquery.mobile.navigation.js \ + js/jquery.mobile.transition.js \ js/jquery.mobile.fixHeaderFooter.js \ js/jquery.mobile.forms.checkboxradio.js \ js/jquery.mobile.forms.textinput.js \ diff --git a/build.xml b/build.xml index 521fc1cd..0024dc22 100644 --- a/build.xml +++ b/build.xml @@ -29,6 +29,7 @@ jquery.mobile.page.js, jquery.mobile.core.js, jquery.mobile.navigation.js, + jquery.mobile.transition.js, jquery.mobile.fixHeaderFooter.js, jquery.mobile.forms.checkboxradio.js, jquery.mobile.forms.textinput.js, diff --git a/js/index.php b/js/index.php index d6683c55..d901581a 100644 --- a/js/index.php +++ b/js/index.php @@ -11,6 +11,7 @@ $elements = array( 'jquery.mobile.page.js', 'jquery.mobile.core.js', 'jquery.mobile.navigation.js', + 'jquery.mobile.transition.js', 'jquery.mobile.fixHeaderFooter.js', 'jquery.mobile.forms.checkboxradio.js', 'jquery.mobile.forms.textinput.js', diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index e3bcb05c..7f64334b 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -313,6 +313,24 @@ //history stack $.mobile.urlHistory = urlHistory; + //default non-animation transition handler + $.mobile.noneTransitionHandler = function(name, reverse, $to, $from){ + if ($from && $from.length){ + $from.removeClass( $.mobile.activePageClass ); + } + $to.addClass( $.mobile.activePageClass ); + + return $.Deferred().resolve(name, reverse, $to, $from).promise(); + }; + + //default handler for unknown transitions + $.mobile.defaultTransitionHandler = $.mobile.noneTransitionHandler; + + //transition handler dictionary for 3rd party transitions + $.mobile.transitionHandlers = { + none: $.mobile.defaultTransitionHandler + }; + //enable cross-domain page support $.mobile.allowCrossDomainPages = false; @@ -412,9 +430,7 @@ $.mobile.silentScroll(); //get current scroll distance - var currScroll = $window.scrollTop(), - perspectiveTransitions = [ "flip" ], - pageContainerClasses = []; + var currScroll = $window.scrollTop(); //support deep-links to generated sub-pages if( url.indexOf( "&" + $.mobile.subPageUrlKey ) > -1 ){ @@ -481,52 +497,19 @@ releasePageTransitionLock(); } - function addContainerClass(className){ - $.mobile.pageContainer.addClass(className); - pageContainerClasses.push(className); - } - - function removeContainerClasses(){ - $.mobile - .pageContainer - .removeClass(pageContainerClasses.join(" ")); - - pageContainerClasses = []; - } - //clear page loader $.mobile.pageLoading( true ); - if(transition && (transition !== 'none')){ - if( $.inArray(transition, perspectiveTransitions) >= 0 ){ - addContainerClass('ui-mobile-viewport-perspective'); - } + //find the transition handler for the specified transition. If there + //isn't one in our transitionHandlers dictionary, use the default one. + //call the handler immediately to kick-off the transition. + var th = $.mobile.transitionHandlers[transition || "none"] || $.mobile.defaultTransitionHandler, + deferred = th(transition, reverse, to, from); - addContainerClass('ui-mobile-viewport-transitioning'); - - if( from ){ - from.addClass( transition + " out " + ( reverse ? "reverse" : "" ) ); - } - to.addClass( $.mobile.activePageClass + " " + transition + - " in " + ( reverse ? "reverse" : "" ) ); - - // callback - remove classes, etc - to.animationComplete(function() { - to.add(from).removeClass("out in reverse " + transition ); - if( from ){ - from.removeClass( $.mobile.activePageClass ); - } - pageChangeComplete(); - removeContainerClasses(); - }); - } - else{ - if( from ){ - from.removeClass( $.mobile.activePageClass ); - } - to.addClass( $.mobile.activePageClass ); + //register a done callback on the transition so we can do some book-keeping cleanup. + deferred.done(function(){ pageChangeComplete(); - } + }); } //shared page enhancements diff --git a/tests/unit/navigation/navigation_transitions.js b/tests/unit/navigation/navigation_transitions.js index 8de0f3ae..5a44806c 100644 --- a/tests/unit/navigation/navigation_transitions.js +++ b/tests/unit/navigation/navigation_transitions.js @@ -2,7 +2,7 @@ * mobile navigation unit tests */ (function($){ - var perspective = "ui-mobile-viewport-perspective", + var perspective = "viewport-flip", transitioning = "ui-mobile-viewport-transitioning", animationCompleteFn = $.fn.animationComplete, diff --git a/themes/default/jquery.mobile.transitions.css b/themes/default/jquery.mobile.transitions.css index 0b828635..a6733e78 100644 --- a/themes/default/jquery.mobile.transitions.css +++ b/themes/default/jquery.mobile.transitions.css @@ -145,13 +145,13 @@ Built by David Kaneda and maintained by Jonathan Stark. -webkit-animation-name: fadeout; } -/* The properties in this body rule are only necessary for the 'flip' transition. +/* The properties in this rule are only necessary for the 'flip' transition. * We need specify the perspective to create a projection matrix. This will add * some depth as the element flips. The depth number represents the distance of * the viewer from the z-plane. According to the CSS3 spec, 1000 is a moderate * value. */ -.ui-mobile-viewport-perspective { +.viewport-flip { -webkit-perspective: 1000; position: absolute; }