Skip to content

1.4.0

Latest

Choose a tag to compare

@byronjohnson byronjohnson released this 21 Nov 20:11
· 1 commit to develop since this release

Include Single thumbnail

A gallery can now keep one image on the page. The rest of the images in that set stay in the HTML and appear only after the lightbox opens. Previous, next, swipe, and the arrow keys still reach them.

Add data-lightbox-cover to a wrapper, or to every trigger in the set. Add data-lightbox-thumb to the image that should stay visible. If you leave that off, the first image in the set is the thumbnail.

Give the set its own data-lightbox-group when other images on the page should stay out of this gallery. A parent that contains only a hidden image, such as a figure, li, or card, is hidden with that image.

<div data-lightbox-group="cabin" data-lightbox-cover>
  <img src="porch.jpg" data-lightbox="porch.jpg" alt="Porch" data-lightbox-thumb>
  <img src="kitchen.jpg" data-lightbox="kitchen.jpg" alt="Kitchen">
  <img src="loft.jpg" data-lightbox="loft.jpg" alt="Loft">
</div>

Call init() after these images are in the page. The hide pass runs once and does not watch for images added later. Pages that do not use data-lightbox-cover skip that pass.

Rename the attributes if those names are already taken:

init({
  coverAttribute: 'data-gallery-cover',
  thumbAttribute: 'data-gallery-thumb'
});