What is the logic of Lightbox 2 on where to position the popup?

北城以北 提交于 2019-12-03 21:43:26

In what way does it display on different places, what is your desired behaviour, and can you give a sample page?

Here is how the script itself calculates the top position of the popup (lightbox v2.04, zip download, js/lightbox.js, lines 229ff):

// calculate top and left offset for the lightbox 
var arrayPageScroll = document.viewport.getScrollOffsets();
var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
var lightboxLeft = arrayPageScroll[0];
this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show();

As the script uses Prototype's document.viewport object, the script positions the popups at 10% inside the current scroll position, like this:

------- page start
|
|
|
|
|
------- scroll position top
|
------- start of lightbox popup
|
|
|
|
|
|
|
|
------ scroll position bottom
|
|
|
|
------ page end

I know this is a very old thread, but still top 5 google results. IE/FF gives me good results but Chrome doesn't. To get them all consistent,

line 231 of js/lightbox.js

var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);

was changed to

var lightboxTop = arrayPageScroll[1] + (100);

Not exactly what was requested, but the pages are consistent now.

Info taken from http://www.lokeshdhakar.com/forums/discussion/5494/fixed-display-position-problems-with-firefox-but-not-ie-on-tall-webpages/p1

Gokhan

In line 231 at lightbox.js adjust division by 10 to 100 like this:

document.viewport.getHeight() / 100

Sample code:

    // calculate top and left offset for the lightbox 
    var arrayPageScroll = document.viewport.getScrollOffsets();
    var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 100); // 
    var lightboxLeft = arrayPageScroll[0];
    this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show();

You could try Flowplayer:

http://flowplayer.org/tools/demos/index.html

You can set the positioning and size of your overlay through the CSS file to wherever you want.

#lightbox{
position: absolute;
top: 100px !important; /*I foxed it 100px from the top, you could fix it as much pixels as you wish*/
} 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!