/**
* Gallery like styled lightbox component for presenting various types of media
* @requires https://github.com/biati-digital/glightbox
*/
import GLightbox from "glightbox";
export default (() => {
const lightboxEl = document.querySelector('[data-glightbox]')
if (lightboxEl === null) return
// Check the dir attribute on html tag and set the default to "ltr" if it's not set or invalid
const htmlElement = document.documentElement
const direction =
htmlElement.getAttribute('dir') === 'ltr' ||
htmlElement.getAttribute('dir') === 'rtl'
? htmlElement.getAttribute('dir')
: 'ltr'
const customLightboxHTML = `
`
const cssEffects =
direction === 'rtl'
? {
slide: { out: 'slideOutRight', in: 'slideInLeft' },
slideBack: { out: 'slideOutLeft', in: 'slideInRight' },
}
: {
slide: { out: 'slideOutLeft', in: 'slideInRight' },
slideBack: { out: 'slideOutRight', in: 'slideInLeft' },
}
/* eslint-disable no-unused-vars, no-undef */
const lightbox = GLightbox({
selector: '[data-glightbox]',
lightboxHTML: customLightboxHTML,
openEffect: 'fade',
closeEffect: 'fade',
closeOnOutsideClick: false,
videosWidth: '1200px',
draggable: direction === 'rtl' ? false : true,
touchNavigation: direction === 'rtl' ? false : true,
cssEfects: cssEffects,
})
/* eslint-enable no-unused-vars, no-undef */
})()