jQuery custom lighbox
- Started
- Last post
- 30 Responses
- juhls
Anyone know of any tutorials on how to make your own lightbox from scratch?
I have the basics, but I need some info about changing the images using "next" and "prev", and assigning keys for those.
Thanks.
- acescence0
here's how to detect if left/right key was pressed...
$(document).keydown(function(e){
switch(e.keyCode){
case 37:
alert('right');
break;
case 39:
alert('left');
break;
};
});
- Stugoo0
funny, i was reading about this earlier today, im done in though. bump it tomorrow and ill see if i can dig out what i was reading.
- nocomply0
I wouldn't try to make your own from scratch, but instead focus on the one that's closest to what you need and hack away at it.
i've made some custom tweaks to the original lightbox (http://www.huddletogether.com/p... in the past. It was a bitch but eventually doable.
Maybe one of the lightboxes that runs off of jQuery would offer more of the controls you're looking for? Can't confirm, just a hunch.
- juhls0
I do use ones people have already made for most projects. Just playing around with it. I may post up my code later and see what you guys think.
- moth0
Lightbox, out of the box, is a right pain in the arse and imo a perfect example of how not to package a jquery plugin.
If you want a version that both works (no horizontal scroll issues) and is more customisable, see this; http://www.digitalia.be/software…
- zarkonite0
I personally like this guy: http://jquery.com/demo/thickbox/…
why do you want to start from scratch?
- acescence0
i think the primary reasons for starting from scratch are that you learn and know exactly how it works, and you end up with some code that does exactly what you want, and not a bunch of extra cruft for features you don't even use. lightbox + all the stuff that makes it go clocks in at 190+ k, you can do the same thing in < 10k if you code it up to do exactly what you need.
- a good approach indeed, I got the impression he had a deadline to meet and had zero knowledge.zarkonite
- juhls0
This is what I have so far. The simplest things are going to kill me. Anyway:
http://pastebin.com/m5da27757I need to make those key presses work (along with the escape button closing the lightbox window), and then add a caption to the image.
Any help would be appreciated. Been at this for hours.
- monNom0
move your previous an next functions out to named functions, rather than anonymous functions following prev.click, next.click
so next.click(function...
becomes
next.click(nextFunc...
and
function nextFunc () {...then call those new functions in your key script.
to add a caption, mimic the '.append' scripts that add the 'close', 'prev' and 'next' buttons to 'displayImage'.
- juhls0
Hmm...the previous and next buttons don't seem to work, and the right and left keypresses keep going back to the same image rather than moving on to the next one.
The "CC" prevents the lightbox from opening up when the page loads.
Thanks for the help though
- attentionspan0
http://www.nickstakenburg.com/pr…
havent tried it but seems like the neatest out there
- neverblink0
I've recently discovered shadowbox, it has a nice feature; it resizes the image on browser resize
- Stugoo0
had issues with most of the above lightboxes for reasons I cannot remeber,
colorbox is the one i use now.
http://colorpowered.com/colorbox…
highly recommend :)
- Daithi0
Colorbox is really good.
- spraycan0
cowbox is nice too
- Chimp0
I've used lightbox on my site. Pretty easy to use, even for a print designer.
- juhls0
This is what I have so far. Messy, I know.
http://pastebin.com/m4a04dbdStill no idea why the caption isn't working, and why "Image 1 of 14" isn't showing up.