Skip to content

Instantly share code, notes, and snippets.

@niklasp
Created May 27, 2021 14:51
Show Gist options
  • Save niklasp/80529fef395ec67192b313f00ce03d0f to your computer and use it in GitHub Desktop.
Save niklasp/80529fef395ec67192b313f00ce03d0f to your computer and use it in GitHub Desktop.
gs5 lightgallery2
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