Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Transition: Calculate "none" after establishing this.toScroll #7143

Closed
wants to merge 2 commits into from
This page is out of date. Refresh to see the latest.
View
13 js/transitions/transition.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 ) {
View
40 tests/unit/transitions/transitions_core.js
@@ -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 );
Something went wrong with that request. Please try again.