Allow left property to be applied to modalCSS option
Closed this issue · 3 comments
Hey,
This is a fantastic modal box. Thank you for sharing it.
I'm trying to modal an image that's a little large and lightbox_me renders out the image too far to the left. Is there a way to control the left property in the same way {top: '40px'} is?
Howdy tristen-
The image should be centered to the window– if lb_me isn't centering it, then the image isn't fully loaded before you invoke lb_me. You need to preload the image and catch the onload event before displaying the lightbox.
Try :
var imgPreloader, $img, myhref = 'your image href';
$clickme.click(function() {
$('#loadingdiv').lightbox_me(); // show a loader so the user knows what's going on
var imgPreloader = new Image; // create an image object to preload the image
imgPreloader.onload = function() { // define the onload of this image obj.
$img = $('<img/>').attr('href', myhref);
$img.lightbox_me();
});
imgPreloader.src = myhref; // set href to the src of the image object. this MUST be defined after the .onload definition.
});
I'm doing this blind, so this is untested, but this is the jist of things.
Gosh! Thanks for this :)
You totally sorted it out for me and knew exactly what I was trying to do.
I wrapped the lightbox_me in an onload function and now everything is peachy :)
Thank you!
No prob, glad you're finding lightbox_me useful!