Accessible, responsive and configurable jQuery lightbox plugin
-
Include jQuery and dependencies:
<script src="path/to/jquery.min.js"></script>
-
Include plugin's code:
<script src="path/to/jquery.lightbox.js"></script>
-
Prepare the HTML for the lightbox(es):
<button data-open-lightbox="lightbox1">Ouvrir la lightbox</button> <div data-lightbox-id="lightbox1" class="lightbox" data-gallery="gallery1"> <div class="lightbox-wrapper"> <p>Lightbox1</p> <button data-close-lightbox="lightbox1">Fermer la lightbox</button> </div> </div> <button data-open-lightbox="lightbox2">Ouvrir la lightbox</button> <div data-lightbox-id="lightbox2" class="lightbox" data-gallery="gallery1"> <div class="lightbox-wrapper"> <p>Lightbox2</p> <button data-close-lightbox="lightbox2">Fermer la lightbox</button> </div> </div>
-
Call the plugin:
// Default configuration $('.lightbox-element').lightbox(); // Custom configuration $('.lightbox-element').lightbox({ keepFocusInside: false, createGallery: true });
Type: Boolean
Default value: true
Keep focus inside the lightbox (can't focus behind it)
Type: String
Default value: null
Element to focus on lightbox open
Type: Boolean
Default value: true
If js animation is activated
Type: Boolean
Default value: false
Create a gallery of lightboxes with lightboxes called with the same "data-gallery"
Navigation will be added to the lightbox wrapper (next and prev)
Type: Boolean
Default value: false
Loop through all lightboxes in the gallery or stop at the end
Type: String
Default value: "fade"
Animation of the lightbox entering the view ("fade" or empty for no animation)
Type: Integer
Default value: 250
Time of the animation in ms
var lightbox = $('.element').open();
lightbox.open();
labels: {
navigationPrev: 'Précédent',
navigationNext: 'Suivant'
}
classes: {
prev: 'prev',
next: 'next',
navigationPrev: "lightbox-prev-button",
navigationNext: "lightbox-next-button",
visuallyhidden: 'visuallyhidden',
states: {
active: 'is-active',
inactive: 'is-inactive'
}
}
Check Releases for detailed changelog.