Skip to content

Commit a3ba990

Browse files
committed
Very prototype-y rework of dialog transitions; globally applying a fade to the dialog’s overlay while applying the specified transition to the dialog itself.
1 parent ded41bb commit a3ba990

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

js/jquery.mobile.transition.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function css3TransitionHandler( name, reverse, $to, $from ) {
1111
viewportClass = "ui-mobile-viewport-transitioning viewport-" + name,
1212
doneFunc = function() {
1313

14-
$to.add( $from ).removeClass( "out in reverse " + name );
14+
$to.add( $from ).removeClass( "out in reverse " + name );
1515

1616
if ( $from && $from[ 0 ] !== $to[ 0 ] ) {
1717
$from.removeClass( $.mobile.activePageClass );
@@ -27,9 +27,32 @@ function css3TransitionHandler( name, reverse, $to, $from ) {
2727
$to.parent().addClass( viewportClass );
2828

2929
if ( $from ) {
30-
$from.addClass( name + " out" + reverseClass );
30+
if ( $from.jqmData('role') === "dialog" ) {
31+
// Transitioning away from a dialog.
32+
33+
$from.addClass( "fade out" + reverseClass );
34+
$to.addClass( $.mobile.activePageClass + " fade out" + reverseClass);
35+
} else {
36+
// Transitioning away from a normal page.
37+
$from.addClass( name + " out" + reverseClass );
38+
}
3139
}
32-
$to.addClass( $.mobile.activePageClass + " " + name + " in" + reverseClass );
40+
41+
if ( $to.jqmData('role') === "dialog" ) {
42+
// Transitioning to a dialog.
43+
44+
// Fade in the dialog overlay:
45+
$to.addClass( $.mobile.activePageClass + " fade in" + reverseClass );
46+
47+
// Apply the set transition to the dialog itself:
48+
$(":first", $to).addClass( name + " in" + reverseClass );
49+
50+
} else if( $from.jqmData('role') !== 'dialog' ){
51+
// Transition has nothing to do with a dialog.
52+
$to.addClass( $.mobile.activePageClass + " " + name + " in" + reverseClass );
53+
}
54+
55+
3356

3457
return deferred.promise();
3558
}
@@ -42,4 +65,4 @@ if ( $.mobile.defaultTransitionHandler === $.mobile.noneTransitionHandler ) {
4265
$.mobile.defaultTransitionHandler = css3TransitionHandler;
4366
}
4467

45-
})( jQuery, this );
68+
})( jQuery, this );

0 commit comments

Comments
 (0)