M
Martin Molema
Hello everyone,
I have a thumbnail gallery and want to create a popup in the center of
the screen. The popup should start at the point clicked and expand to
the center of the screen.
Problem is that "what is the center of the screen" when there is a
scrollbar. I probably should take into account the position of the
vertical scrollbar? Where do I find that property?
What I do now is obtain the document's outerheight and the point
clicked and try to figure out where to zoom / pan to. However:
document.body.clientHeight is always 40! If I use Firebug plugin in
Firefox, the body is reported as (e.g.) 1686. The document.outerHeight
is often around 860 (somewhere windows screen size), but nowhere can I
find the value 1686,
Code is below:
[code snippet]
viewWidth = window.innerWidth > document.body.clientWidth ?
window.innerWidth : document.body.clientWidth;
viewHeight = window.outerHeight > document.body.clientHeight ?
window.outerHeight : document.body.clientHeight;
if (aspectRatio < 1){
gZoomWidth = viewWidth / 2;
gZoomHeight = gZoomWidth * aspectRatio;
}
else{
gZoomHeight = viewHeight / 1.5;
gZoomWidth = gZoomHeight / aspectRatio;
}
gZoomPosX = viewWidth / 2 - gZoomWidth / 2;
gZoomPosY = viewHeight / 2 - gZoomHeight / 2;
img.width = 1;
img.height = 1;
img.src = getLargeImageSrc(thumb.src);
if (thumb){
gDiv.style.top = thumb.offsetParent.offsetTop + "px";
gDiv.style.left = thumb.offsetParent.offsetLeft + "px";
gDiv.style.height = 10 + "px";
gDiv.style.width = 10 + "px";
increaseSize();
}
[/code snippet]
Example at http://www.molema.org/subpages/fotos/showThumbnails.php?id=DIR19
Any help is welcome
Greets Martin
I have a thumbnail gallery and want to create a popup in the center of
the screen. The popup should start at the point clicked and expand to
the center of the screen.
Problem is that "what is the center of the screen" when there is a
scrollbar. I probably should take into account the position of the
vertical scrollbar? Where do I find that property?
What I do now is obtain the document's outerheight and the point
clicked and try to figure out where to zoom / pan to. However:
document.body.clientHeight is always 40! If I use Firebug plugin in
Firefox, the body is reported as (e.g.) 1686. The document.outerHeight
is often around 860 (somewhere windows screen size), but nowhere can I
find the value 1686,
Code is below:
[code snippet]
viewWidth = window.innerWidth > document.body.clientWidth ?
window.innerWidth : document.body.clientWidth;
viewHeight = window.outerHeight > document.body.clientHeight ?
window.outerHeight : document.body.clientHeight;
if (aspectRatio < 1){
gZoomWidth = viewWidth / 2;
gZoomHeight = gZoomWidth * aspectRatio;
}
else{
gZoomHeight = viewHeight / 1.5;
gZoomWidth = gZoomHeight / aspectRatio;
}
gZoomPosX = viewWidth / 2 - gZoomWidth / 2;
gZoomPosY = viewHeight / 2 - gZoomHeight / 2;
img.width = 1;
img.height = 1;
img.src = getLargeImageSrc(thumb.src);
if (thumb){
gDiv.style.top = thumb.offsetParent.offsetTop + "px";
gDiv.style.left = thumb.offsetParent.offsetLeft + "px";
gDiv.style.height = 10 + "px";
gDiv.style.width = 10 + "px";
increaseSize();
}
[/code snippet]
Example at http://www.molema.org/subpages/fotos/showThumbnails.php?id=DIR19
Any help is welcome
Greets Martin