Permalink
Browse files

Transition: Calculate "none" after establishing this.toScroll

Closes gh-7143
Fixes gh-7140
  • Loading branch information...
gabrielschulhof committed Feb 20, 2014
1 parent 5bbb46a commit c358947354c968e02dd0670b4003675308ed07c2
Showing with 50 additions and 3 deletions.
  1. +10 −3 js/transitions/transition.js
  2. +40 −0 tests/unit/transitions/transitions_core.js
@@ -144,12 +144,19 @@ define( [ "jquery",
// better transitions with fewer bugs. Ie, it's not guaranteed that the
// object will be created and transition will be run immediately after as
// it is today. So we wait until transition is invoked to gather the following
- var reverseClass = this.reverse ? " reverse" : "",
+ var none,
+ reverseClass = this.reverse ? " reverse" : "",
screenHeight = $.mobile.getScreenHeight(),
- maxTransitionOverride = $.mobile.maxTransitionWidth !== false && $.mobile.window.width() > $.mobile.maxTransitionWidth,
- none = !$.support.cssTransitions || !$.support.cssAnimations || maxTransitionOverride || !this.name || this.name === "none" || Math.max( $.mobile.window.scrollTop(), this.toScroll ) > $.mobile.getMaxScrollForTransition();
+ maxTransitionOverride = $.mobile.maxTransitionWidth !== false &&
+ $.mobile.window.width() > $.mobile.maxTransitionWidth;
this.toScroll = $.mobile.navigate.history.getActive().lastScroll || $.mobile.defaultHomeScroll;
+
+ none = !$.support.cssTransitions || !$.support.cssAnimations ||
+ maxTransitionOverride || !this.name || this.name === "none" ||
+ Math.max( $.mobile.window.scrollTop(), this.toScroll ) >
+ $.mobile.getMaxScrollForTransition();
+
this.toggleViewportClass();
if ( this.$from && !none ) {
@@ -194,4 +194,44 @@
instance.transition();
});
+
+ test( "transition respects getMaxScrollForTransition", function() {
+ var transition, valuePassedToNone,
+ original = {
+ maxScroll: $.mobile.getMaxScrollForTransition,
+ startOut: $.mobile.Transition.prototype.startOut,
+ doneOut: $.mobile.Transition.prototype.doneOut,
+ defaultHomeScroll: $.mobile.defaultHomeScroll
+ },
+ startOutCalled = false,
+ doneOutCalled = false;
+
+ $.mobile.getMaxScrollForTransition = function() {
+ return -1;
+ };
+
+ $.mobile.Transition.prototype.startOut = function( screenHeight, reverseClass, none ) {
+ startOutCalled = true;
+ return original.startOut.apply( this, arguments );
+ };
+
+ $.mobile.Transition.prototype.doneOut = function( height, reverse, none, preventFocus ) {
+ doneOutCalled = true;
+ valuePassedToNone = none;
+ return original.doneOut.apply( this, arguments );
+ };
+
+ $.mobile.defaultHomeScroll = 0;
+
+ ( new $.mobile.Transition( "slide", false, $([]), $([]) ) ).transition();
+
+ deepEqual( startOutCalled, false, "startOut was not called" );
+ deepEqual( doneOutCalled, true, "doneOut was called" );
+ deepEqual( valuePassedToNone, true, "The value passed to none was true" );
+
+ $.mobile.getMaxScrollForTransition = original.maxScroll;
+ $.mobile.Transition.prototype.startOut = original.startOut;
+ $.mobile.Transition.prototype.doneOut = original.doneOut;
+ $.mobile.defaultHomeScroll = original.defaultHomeScroll;
+ });
})( jQuery );

0 comments on commit c358947

Please sign in to comment.