Skip to content

Commit 16c375d

Browse files
committed
Dialog: Use proper position data after drag and resize. Fixes #9351 - Dialog: Incorrect value for position option after resize.
1 parent a9bb488 commit 16c375d

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

ui/jquery.ui.dialog.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,15 @@ $.widget( "ui.dialog", {
454454
that._trigger( "drag", event, filteredUi( ui ) );
455455
},
456456
stop: function( event, ui ) {
457-
options.position = [
458-
ui.position.left - that.document.scrollLeft(),
459-
ui.position.top - that.document.scrollTop()
460-
];
457+
var left = ui.offset.left - that.document.scrollLeft(),
458+
top = ui.offset.top - that.document.scrollTop();
459+
460+
options.position = {
461+
my: "left top",
462+
at: "left" + (left >= 0 ? "+" : "") + left + " " +
463+
"top" + (top >= 0 ? "+" : "") + top,
464+
of: that.window
465+
};
461466
$( this ).removeClass("ui-dialog-dragging");
462467
that._unblockFrames();
463468
that._trigger( "dragStop", event, filteredUi( ui ) );
@@ -503,8 +508,18 @@ $.widget( "ui.dialog", {
503508
that._trigger( "resize", event, filteredUi( ui ) );
504509
},
505510
stop: function( event, ui ) {
506-
options.height = $( this ).height();
507-
options.width = $( this ).width();
511+
var offset = that.uiDialog.offset(),
512+
left = offset.left - that.document.scrollLeft(),
513+
top = offset.top - that.document.scrollTop();
514+
515+
options.height = that.uiDialog.height();
516+
options.width = that.uiDialog.width();
517+
options.position = {
518+
my: "left top",
519+
at: "left" + (left >= 0 ? "+" : "") + left + " " +
520+
"top" + (top >= 0 ? "+" : "") + top,
521+
of: that.window
522+
};
508523
$( this ).removeClass("ui-dialog-resizing");
509524
that._unblockFrames();
510525
that._trigger( "resizeStop", event, filteredUi( ui ) );

0 commit comments

Comments
 (0)