views:

344

answers:

3

When using Facebox I notice that it loads to the left of the screen and then jumps to the centre. Is there a fix so that it loads in the centre from the start without the jump?

+1  A: 

I had the same problem with Facebox version 1.2. it disappeared when I went back to using version 1.1.

bee
+1  A: 

This is due to line 126 in facebox.js:

left: 385.5

This occurs within the loading function.

As you see the position of facebox has been hard coded.

I fixed this in my case by changing this line to:

left: $(window).width() / 2 - (490 / 2)

(NOTE: change 490 from my example to the width of your #facebox table)

Jonathan Nicol
Excellent tip. Thanks.The only thing is that the content of the box has to be the same width for all faceboxes to be opened without jumping. It would be good to dynamically calculate the with of the content and replace "490" with that.
Model Reject
@Clint - Yeah I thought of that too, but it doesn't look like there is a simple way to do it. Because the facebox has display:none it is impossible to measure its width. I'm sure a JS/jQuery guru could come up with a solution (perhaps clone the facebox, position it off screen, measure it and then destroy the clone), but for my purposes I was happy to hard code the width.
Jonathan Nicol
Maybe it is just the content that needs measured. That can be done, then add the padding or whatever facebox has added to that number. Then we a have a width to work with. Will try that out...when I get some time.
Model Reject