banthagroup / fslightbox

An easy to use vanilla JavaScript plug-in without production dependencies for displaying images, videos, or, through custom sources, anything you want in a clean overlying box.
MIT License
351 stars 30 forks source link

Is there a way to load multiple lightboxes from single image? #204

Closed pwolke closed 1 year ago

pwolke commented 2 years ago

I'm coding a portfolio where there will be a few thumbnail images. Each thumbnail image will represent a project. Each project will have ten (for example) photos in it. I would like the click of the thumbnail image to load the first of the ten lightbox images. Once in the modal, you can navigate through the remaining ten items.

piotrzdziarski commented 1 year ago
var l1 = new FsLightbox(), l2 = new FsLightbox();
l1.props.sources = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg", "7.jpg", "8.jpg", "9.jpg", "10.jpg"];
l2.props.sources = ["11.jpg", "12.jpg", "13.jpg", "14.jpg", "15.jpg", "16.jpg", "17.jpg", "18.jpg", "19.jpg", "20.jpg"];

document.getElementById("thumbnail-1").onclick = function() {
    l1.open()
};
document.getElementById("thumbnail-2").onclick = function() {
    l2.open()
}