Last active
January 11, 2021 15:42
-
-
Save cutme/3984fced7de04dcf95e7de24d5afdb4a to your computer and use it in GitHub Desktop.
[Glightbox] Open image in lightbox #glightbox #lightbox #javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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