Skip to content

Commit d62e1a8

Browse files
author
Peter
committed
popup.js: Added support for reverse transitions
Fixes jquery-archive#4743 - Popup transition direction reverse by adding support for data-direction="reverse" on popup widget links.
1 parent 7f312da commit d62e1a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

js/widgets/popup.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ define( [ "jquery",
4444
shadow: true,
4545
corners: true,
4646
transition: "none",
47+
direction: null,
4748
positionTo: "origin",
4849
tolerance: null,
4950
initSelector: ":jqmData(role='popup')"
@@ -158,6 +159,7 @@ define( [ "jquery",
158159
_ui: ui,
159160
_fallbackTransition: "",
160161
_currentTransition: false,
162+
_isReversed: false,
161163
_prereqs: null,
162164
_isOpen: false,
163165
_tolerance: null,
@@ -240,6 +242,7 @@ define( [ "jquery",
240242
if ( value && value !== "none" ) {
241243
this._fallbackTransition = $.mobile._maybeDegradeTransition( value );
242244
this._ui.container.addClass( this._fallbackTransition );
245+
if (this._isReversed) this._ui.container.toggleClass( "reverse" );
243246
}
244247
},
245248

@@ -499,6 +502,7 @@ define( [ "jquery",
499502

500503
if ( transition ) {
501504
this._currentTransition = transition;
505+
if (options.direction === "reverse" ) this._isReversed = true;
502506
this._applyTransition( transition );
503507
} else {
504508
transition = this.options.transition;
@@ -560,7 +564,7 @@ define( [ "jquery",
560564
transition: ( this._currentTransition || this.options.transition ),
561565
classToRemove: "in",
562566
screenClassToAdd: "out",
563-
containerClassToAdd: "reverse out",
567+
containerClassToAdd: this._isReversed ? "out" : "reverse out",
564568
applyTransition: true,
565569
prereqs: this._prereqs
566570
});
@@ -741,6 +745,7 @@ define( [ "jquery",
741745
x: offset.left + $link.outerWidth() / 2,
742746
y: offset.top + $link.outerHeight() / 2,
743747
transition: $link.jqmData( "transition" ),
748+
direction: $link.jqmDate( "direction" ),
744749
positionTo: $link.jqmData( "position-to" )
745750
});
746751

0 commit comments

Comments
 (0)