ArielOctavio / jquery-dialogextend

Automatically exported from code.google.com/p/jquery-dialogextend
0 stars 0 forks source link

Restoring original position after minimizing dialog #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Scroll page horizontally.
2. Open dialog with min option enabled.
3. Minimize and restore dialog.

What is the expected output? What do you see instead?
Restored dialog is positioned at the bottom of the viewport instead of original 
position.

What version of the product are you using? On what operating system?
1.0.1 - Firefox under Windows with jQuery UI 1.9.2 and jQuery 1.8.3 and 
original position mode set as absolute

Please provide any additional information below.
What is wrong?

You save absolutely positioned coorditanates from original dialog:

.data("original-position-left", $(self).dialog("widget").offset().left)
.data("original-position-top", $(self).dialog("widget").offset().top)

but to restore original position you use
"position" : [ original.position.left, original.position.top ]

The jQuery dialog takes a position parameter which is measured from the top 
left corner of the current viewport. In other words, [0, 0] will always put it 
in the upper left hand corner of your browser window, regardless of where you 
are currently scrolled to. To fix that issue you have to save original position 
related to viewport, not the absolute ones. So we have to correct that absolute 
values by scroll position:

.data("original-position-top", $(self).dialog("widget").offset().top - 
$(document).scrollTop())

Original issue reported on code.google.com by saba...@gmail.com on 31 Oct 2013 at 10:30

GoogleCodeExporter commented 9 years ago
Should be
1. Scroll page vertically.

Original comment by saba...@gmail.com on 31 Oct 2013 at 10:32