Created
May 27, 2021 14:51
-
-
Save niklasp/80529fef395ec67192b313f00ce03d0f to your computer and use it in GitHub Desktop.
gs5 lightgallery2
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
const gsBgImgSelector = '.wp-block-eedee-block-gutenslider .eedee-background-div img'; | |
const dynamicEl = [ ...el.querySelectorAll( gsBgImgSelector ) ].map( ( sliderImg ) => { | |
return { | |
src: sliderImg.src, | |
thumb: sliderImg.src, | |
subHtml: '<h4>Image 1 title</h4><p>Image 1 descriptions.</p>', | |
}; | |
}); | |
const dynamicGallery = document.querySelector('.dynamic-gallery-button'); | |
dynamicGallery.addEventListener('click', () => { | |
const popup = lightGallery( dynamicGallery, { | |
dynamic: true, | |
dynamicEl, | |
}); | |
setTimeout(() => { | |
console.log( popup ); | |
popup.openGallery( 0 ); | |
}, 1000); | |
}); | |
[ ...document.querySelectorAll( '.wp-block-eedee-block-gutenslide' ) ].map( ( slide, idx ) => { | |
slide.addEventListener('click', () => { | |
const popup = lightGallery( slide, { | |
dynamic: true, | |
dynamicEl, | |
}); | |
setTimeout(() => { | |
console.log( popup ); | |
popup.openGallery( idx ); | |
}, 1000); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment