Skip to content

Instantly share code, notes, and snippets.

@cutme
Last active January 11, 2021 15:42
Show Gist options
  • Save cutme/3984fced7de04dcf95e7de24d5afdb4a to your computer and use it in GitHub Desktop.
Save cutme/3984fced7de04dcf95e7de24d5afdb4a to your computer and use it in GitHub Desktop.
[Glightbox] Open image in lightbox #glightbox #lightbox #javascript
/*
* Open image in gLightbox (https://github.com/mcstudios/glightbox)
*
* Usage:
* <a hre="picture.jpg" class="js-image">Open picture</a>
*/
import GLightbox from 'glightbox';
require('../../node_modules/glightbox/dist/css/glightbox.css');
document.addEventListener('DOMContentLoaded', function() {
if (document.getElementsByClassName('js-image').length > 0) {
let image = GLightbox({
selector: 'js-image'
});
const video = GLightbox({
selector: "[href*='youtube']"
});
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment