Window not getting centered on body with scroll

We have a window which is attached to document.body which is the default behavior.
We are calling centerOnScreen which centers the window correctly when there are no scroll bars.
But the moment body has a scroll bar and we are at the end of the browser window, the window opens up but is not centered so user never comes to see the popup, user has to scroll up all the way to see the popup.
The modal is also set to true, but the modal effect is only applied to top portion of windw, seems like this also might be happening due to presense of scroll bar.



to solve the problem with modal effect you may try to attach viewport to the overall container.

The following allows to correct window position:

var pos = win.getPosition();
var offset =(document.body.scrollTop?document.body.scrollTop:window.pageYOffset);

I’ve attached the sample (41 KB)

Thanks for responding,

I tried putting the following code to make this work with the sample, this seems to work. i.e, makes the modal window expand to the whole document not just the first screen full = docHeight; = docHeight;

above docHeight is the height of the document, this is needed because I have enableAutoViewPort set to true. Which I guess will make the window attached to the document.

Your code for centering the popup, does not seem to work when I have a lot of scroll on the page, I tried adding the following code,

     var scroll =(document.body.scrollTop ? document.body.scrollTop : window.pageYOffset);
     if(typeof scroll !== 'undefined' && scroll !== null) {
	alert('scroll calculated = ' + scroll);
	var pos2 = w1.getPosition();
	alert('pos y after setting = ' + pos2[1]);

the second alert after calling setPosition() of the window does print the y position that I passi nteh previous setPosition call, the y position seems to be limited to 863px for some reason.

Please let me know if you need anything else to debug this issue.


Locally the same works correctly (have a look at the attached sample) (41.1 KB)

I tried your example and it does work,
BUT when I do the following,
i.e, make document as the viewport for the window. Now with this change in code, if I start to scroll down and hit the center on screen, the window does not center, and on my screen the maximum y position echoed in the alert box this time is 600px (because I am trying this from another computer), it might be different on your screen. Try to scroll down as much as possible and then try to center the popup.


As I wrote before the overall container as the viewport the best solution to solve that problem. In this case it’s possible to calculate sizes correctly.

Therefore, try using the approach from the sample

I have the same problem. In my case, i cant have the viewport to contain the page. Is there another way to correct this problem ? Im using Pro v.3.0

My project involves a global button (appears on any pages on my site, so the idea of a viewport contain whole page is impossible) which fire up Windows