Provide option to exclude img from photoswipe

Hides all images with the attribute `photoswipe="false"`.
This commit is contained in:
NoahPeeters 2020-07-04 00:09:48 +02:00
parent 6757d0f3b1
commit f9c4cf44d6
No known key found for this signature in database
GPG Key ID: 42C12BA79E84A851
1 changed files with 11 additions and 6 deletions

View File

@ -99,7 +99,6 @@ document.addEventListener('DOMContentLoaded', function () {
var captionElem = document.querySelector('.modal__caption');
var pagingElem = document.querySelector('.modal__paging');
var itemsElem = document.querySelector('.modal__items');
var imgTotalNum = null;
var myFadeTimeout = null;
var mySwipe = null;
var keydownFunction = function (e) {
@ -114,13 +113,19 @@ document.addEventListener('DOMContentLoaded', function () {
}
}
if (galleryContainerElem) {
imgTotalNum = galleryContainerElem.querySelectorAll('img').length;
} else {
if (!galleryContainerElem) {
galleryContainerElem = document.querySelector('.single__contents');
imgTotalNum = galleryContainerElem.querySelectorAll('img').length;
}
var allImages = [];
galleryContainerElem.querySelectorAll('img').forEach(function (elem) {
if (elem.getAttribute('photoswipe') != "false") {
allImages.push(elem);
}
});
var imgTotalNum = allImages.length;
MicroModal.init({
onClose: function () {
if (mySwipe) {
@ -148,7 +153,7 @@ document.addEventListener('DOMContentLoaded', function () {
});
}
galleryContainerElem.querySelectorAll('img').forEach(function (elem, idx) {
allImages.forEach(function (elem, idx) {
elem.style.cursor = 'pointer';
var clonedElem = elem.cloneNode(true);