New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parvus

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parvus - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

202

dist/js/parvus.esm.js

@@ -5,3 +5,3 @@ /**

* @author Benjamin de Oostfrees
* @version 2.0.3
* @version 2.0.4
* @url https://github.com/deoostfrees/parvus

@@ -34,3 +34,3 @@ *

};
let groups = {};
const GROUPS = {};
let newGroup = null;

@@ -177,2 +177,3 @@ let activeGroup = null;

const getGroup = function getGroup(el) {
// Create a unique ID
const GROUP_ID = Math.floor(Math.random() * 10000);

@@ -211,9 +212,9 @@

if (!Object.prototype.hasOwnProperty.call(groups, newGroup)) {
groups[newGroup] = copyObject(GROUP_ATTS);
if (!Object.prototype.hasOwnProperty.call(GROUPS, newGroup)) {
GROUPS[newGroup] = copyObject(GROUP_ATTS);
} // Check if element already exists
if (!groups[newGroup].gallery.includes(el)) {
groups[newGroup].gallery.push(el);
if (!GROUPS[newGroup].gallery.includes(el)) {
GROUPS[newGroup].gallery.push(el);

@@ -233,5 +234,5 @@ if (el.querySelector('img') !== null) {

if (isOpen() && newGroup === activeGroup) {
createSlide(el, groups[newGroup].gallery.indexOf(el));
createImage(el, groups[newGroup].gallery.indexOf(el), function () {
loadImage(groups[newGroup].gallery.indexOf(el));
createSlide(GROUPS[newGroup].gallery.indexOf(el));
createImage(el, GROUPS[newGroup].gallery.indexOf(el), function () {
loadImage(GROUPS[newGroup].gallery.indexOf(el));
});

@@ -260,3 +261,3 @@ updateConfig();

if (!groups[GROUP].gallery.includes(el)) {
if (!GROUPS[GROUP].gallery.includes(el)) {
throw new Error('Ups, I can\'t find the element.');

@@ -266,3 +267,3 @@ } // TODO: Remove elements dynamically

groups[GROUP].gallery.splice(groups[GROUP].gallery.indexOf(el), 1); // Remove lightbox indicator icon if necessary
GROUPS[GROUP].gallery.splice(GROUPS[GROUP].gallery.indexOf(el), 1); // Remove lightbox indicator icon if necessary

@@ -349,7 +350,7 @@ if (el.classList.contains('parvus-zoom')) {

const createSlider = function createSlider() {
groups[activeGroup].slider = document.createElement('div');
groups[activeGroup].slider.className = 'parvus__slider'; // Hide slider
GROUPS[activeGroup].slider = document.createElement('div');
GROUPS[activeGroup].slider.className = 'parvus__slider'; // Hide slider
groups[activeGroup].slider.setAttribute('aria-hidden', 'true');
lightbox.appendChild(groups[activeGroup].slider);
GROUPS[activeGroup].slider.setAttribute('aria-hidden', 'true');
lightbox.appendChild(GROUPS[activeGroup].slider);
};

@@ -360,8 +361,7 @@ /**

* @param {HTMLElement} el
* @param {Number} index
*/
const createSlide = function createSlide(el, index) {
if (groups[activeGroup].sliderElements[index] !== undefined) ; else {
const createSlide = function createSlide(index) {
if (GROUPS[activeGroup].sliderElements[index] !== undefined) ; else {
const SLIDER_ELEMENT = document.createElement('div');

@@ -376,12 +376,12 @@ const SLIDER_ELEMENT_CONTENT = document.createElement('div');

SLIDER_ELEMENT.appendChild(SLIDER_ELEMENT_CONTENT);
groups[activeGroup].sliderElements[index] = SLIDER_ELEMENT; // Add slider element to slider
GROUPS[activeGroup].sliderElements[index] = SLIDER_ELEMENT; // Add slider element to slider
if (index === currentIndex) {
groups[activeGroup].slider.appendChild(SLIDER_ELEMENT);
GROUPS[activeGroup].slider.appendChild(SLIDER_ELEMENT);
}
if (index > currentIndex) {
groups[activeGroup].sliderElements[currentIndex].after(SLIDER_ELEMENT);
GROUPS[activeGroup].sliderElements[currentIndex].after(SLIDER_ELEMENT);
} else {
groups[activeGroup].sliderElements[currentIndex].before(SLIDER_ELEMENT);
GROUPS[activeGroup].sliderElements[currentIndex].before(SLIDER_ELEMENT);
}

@@ -404,7 +404,7 @@ }

if (!groups[activeGroup].gallery.includes(el)) {
if (!GROUPS[activeGroup].gallery.includes(el)) {
throw new Error('Ups, I can\'t find the element.');
}
currentIndex = groups[activeGroup].gallery.indexOf(el); // Save user’s focus
currentIndex = GROUPS[activeGroup].gallery.indexOf(el); // Save user’s focus

@@ -430,5 +430,5 @@ lastFocus = document.activeElement; // Use `history.pushState()` to make sure the 'Back' button behavior

createSlider();
createSlide(el, currentIndex); // Show slider
createSlide(currentIndex); // Show slider
groups[activeGroup].slider.setAttribute('aria-hidden', 'false');
GROUPS[activeGroup].slider.setAttribute('aria-hidden', 'false');
updateOffset();

@@ -453,3 +453,3 @@ updateConfig();

groups[activeGroup].slider.classList.add('parvus__slider--animate');
GROUPS[activeGroup].slider.classList.add('parvus__slider--animate');
}); // Create and dispatch a new event

@@ -475,5 +475,5 @@

const IMAGE = groups[activeGroup].images[currentIndex];
const IMAGE = GROUPS[activeGroup].images[currentIndex];
const IMAGE_SIZE = IMAGE.getBoundingClientRect();
const THUMBNAIL = config.backFocus ? groups[activeGroup].gallery[currentIndex] : lastFocus;
const THUMBNAIL = config.backFocus ? GROUPS[activeGroup].gallery[currentIndex] : lastFocus;
const THUMBNAIL_SIZE = THUMBNAIL.getBoundingClientRect();

@@ -512,3 +512,3 @@ unbindEvents();

lastFocus = config.backFocus ? groups[activeGroup].gallery[currentIndex] : lastFocus;
lastFocus = config.backFocus ? GROUPS[activeGroup].gallery[currentIndex] : lastFocus;
lastFocus.focus({

@@ -521,8 +521,8 @@ preventScroll: true

lightbox.classList.remove('parvus--is-vertical-closing');
IMAGE.style.transform = ''; // Reset groups
IMAGE.style.transform = ''; // Reset GROUPS
groups[activeGroup].slider.remove();
groups[activeGroup].slider = null;
groups[activeGroup].sliderElements = [];
groups[activeGroup].images = [];
GROUPS[activeGroup].slider.remove();
GROUPS[activeGroup].slider = null;
GROUPS[activeGroup].sliderElements = [];
GROUPS[activeGroup].images = [];
}, {

@@ -534,3 +534,3 @@ once: true

detail: {
source: groups[activeGroup].gallery[currentIndex]
source: GROUPS[activeGroup].gallery[currentIndex]
}

@@ -548,8 +548,8 @@ });

const preload = function preload(index) {
if (groups[activeGroup].gallery[index] === undefined) {
if (GROUPS[activeGroup].gallery[index] === undefined) {
return;
}
createSlide(groups[activeGroup].gallery[index], index);
createImage(groups[activeGroup].gallery[index], index, function () {
createSlide(index);
createImage(GROUPS[activeGroup].gallery[index], index, function () {
loadImage(index);

@@ -566,4 +566,4 @@ });

const loadSlide = function loadSlide(index) {
groups[activeGroup].sliderElements[index].classList.add('parvus__slide--is-active');
groups[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'false');
GROUPS[activeGroup].sliderElements[index].classList.add('parvus__slide--is-active');
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'false');
};

@@ -573,5 +573,5 @@ /**

*
* @param {HTMLElement} el
* @param {Number} index
* @param {HTMLElement} el
* @param {HTMLElement} container
* @param {Function} callback
*/

@@ -581,4 +581,4 @@

const createImage = function createImage(el, index, callback) {
if (groups[activeGroup].images[index] !== undefined) ; else {
const container = groups[activeGroup].sliderElements[index].querySelector('div');
if (GROUPS[activeGroup].images[index] !== undefined) ; else {
const container = GROUPS[activeGroup].sliderElements[index].querySelector('div');
const IMAGE = document.createElement('img');

@@ -603,3 +603,3 @@ const IMAGE_CONTAINER = document.createElement('div');

IMAGE.setAttribute('height', IMAGE.naturalHeight);
setImageDimension(groups[activeGroup].sliderElements[index], IMAGE);
setImageDimension(GROUPS[activeGroup].sliderElements[index], IMAGE);

@@ -631,3 +631,3 @@ if (callback && typeof callback === 'function') {

IMAGE_CONTAINER.appendChild(IMAGE);
groups[activeGroup].images[index] = IMAGE;
GROUPS[activeGroup].images[index] = IMAGE;
container.appendChild(IMAGE_CONTAINER); // Add caption if available

@@ -655,2 +655,4 @@

if (captionData !== null) {
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-labelledby', `parvus__caption-${index}`);
CAPTION_CONTAINER.id = `parvus__caption-${index}`;
CAPTION_CONTAINER.innerHTML = `<p>${captionData}</p>`;

@@ -670,5 +672,5 @@ container.appendChild(CAPTION_CONTAINER);

const loadImage = function loadImage(index) {
const IMAGE = groups[activeGroup].images[index];
const IMAGE = GROUPS[activeGroup].images[index];
const IMAGE_SIZE = IMAGE.getBoundingClientRect();
const THUMBNAIL = groups[activeGroup].gallery[index];
const THUMBNAIL = GROUPS[activeGroup].gallery[index];
const THUMBNAIL_SIZE = THUMBNAIL.getBoundingClientRect();

@@ -698,7 +700,7 @@

*
* @param {Number} newIndex
* @param {Number} index
*/
const select = function select(newIndex) {
const select = function select(index) {
const OLD_INDEX = currentIndex;

@@ -709,12 +711,12 @@

} else {
if (!newIndex && newIndex !== 0) {
if (!index && index !== 0) {
throw new Error('Ups, no slide specified.');
}
if (newIndex === currentIndex) {
throw new Error(`Ups, slide ${newIndex} is already selected.`);
if (index === currentIndex) {
throw new Error(`Ups, slide ${index} is already selected.`);
}
if (newIndex === -1 || newIndex >= groups[activeGroup].gallery.length) {
throw new Error(`Ups, I can't find slide ${newIndex}.`);
if (index === -1 || index >= GROUPS[activeGroup].gallery.length) {
throw new Error(`Ups, I can't find slide ${index}.`);
}

@@ -724,6 +726,6 @@ }

leaveSlide(OLD_INDEX);
loadSlide(newIndex);
loadImage(newIndex);
loadSlide(index);
loadImage(index);
if (newIndex < OLD_INDEX) {
if (index < OLD_INDEX) {
currentIndex--;

@@ -733,6 +735,6 @@ updateOffset();

updateFocus('left');
preload(newIndex - 1);
preload(index - 1);
}
if (newIndex > OLD_INDEX) {
if (index > OLD_INDEX) {
currentIndex++;

@@ -742,3 +744,3 @@ updateOffset();

updateFocus('right');
preload(newIndex + 1);
preload(index + 1);
}

@@ -750,3 +752,3 @@

detail: {
source: groups[activeGroup].gallery[currentIndex]
source: GROUPS[activeGroup].gallery[currentIndex]
}

@@ -774,3 +776,3 @@ });

const next = function next() {
if (currentIndex < groups[activeGroup].gallery.length - 1) {
if (currentIndex < GROUPS[activeGroup].gallery.length - 1) {
select(currentIndex + 1);

@@ -788,4 +790,4 @@ }

const leaveSlide = function leaveSlide(index) {
groups[activeGroup].sliderElements[index].classList.remove('parvus__slide--is-active');
groups[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'true');
GROUPS[activeGroup].sliderElements[index].classList.remove('parvus__slide--is-active');
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'true');
};

@@ -801,3 +803,3 @@ /**

offset = currentIndex * lightbox.offsetWidth * -1;
groups[activeGroup].slider.style.transform = `translate3d(${offset}px, 0, 0)`;
GROUPS[activeGroup].slider.style.transform = `translate3d(${offset}px, 0, 0)`;
offsetTmp = offset;

@@ -813,3 +815,3 @@ };

const updateFocus = function updateFocus(dir) {
if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
closeButton.focus();

@@ -820,3 +822,3 @@ } else {

nextButton.focus(); // If the last slide is displayed
} else if (currentIndex === groups[activeGroup].gallery.length - 1) {
} else if (currentIndex === GROUPS[activeGroup].gallery.length - 1) {
previousButton.focus();

@@ -839,3 +841,3 @@ } else {

const updateCounter = function updateCounter() {
counter.textContent = `${currentIndex + 1}/${groups[activeGroup].gallery.length}`;
counter.textContent = `${currentIndex + 1}/${GROUPS[activeGroup].gallery.length}`;
};

@@ -870,3 +872,3 @@ /**

previous();
} else if (isDraggingX && MOVEMENT_X < 0 && MOVEMENT_X_DISTANCE >= config.threshold && currentIndex !== groups[activeGroup].gallery.length - 1) {
} else if (isDraggingX && MOVEMENT_X < 0 && MOVEMENT_X_DISTANCE >= config.threshold && currentIndex !== GROUPS[activeGroup].gallery.length - 1) {
next();

@@ -892,8 +894,8 @@ } else if (isDraggingY && MOVEMENT_Y_DISTANCE > 0) {

const updateConfig = function updateConfig() {
if (config.swipeClose && !groups[activeGroup].slider.classList.contains('parvus__slider--is-draggable') || groups[activeGroup].gallery.length > 1 && !groups[activeGroup].slider.classList.contains('parvus__slider--is-draggable')) {
groups[activeGroup].slider.classList.add('parvus__slider--is-draggable');
if (config.swipeClose && !GROUPS[activeGroup].slider.classList.contains('parvus__slider--is-draggable') || GROUPS[activeGroup].gallery.length > 1 && !GROUPS[activeGroup].slider.classList.contains('parvus__slider--is-draggable')) {
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-draggable');
} // Hide buttons if necessary
if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
previousButton.setAttribute('aria-hidden', 'true');

@@ -910,3 +912,3 @@ previousButton.disabled = true;

nextButton.disabled = false; // If the last slide is displayed
} else if (currentIndex === groups[activeGroup].gallery.length - 1) {
} else if (currentIndex === GROUPS[activeGroup].gallery.length - 1) {
previousButton.setAttribute('aria-hidden', 'false');

@@ -925,3 +927,3 @@ previousButton.disabled = false;

if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
counter.setAttribute('aria-hidden', 'true');

@@ -942,3 +944,5 @@ } else {

BROWSER_WINDOW.requestAnimationFrame(() => {
setImageDimension(groups[activeGroup].sliderElements[currentIndex], groups[activeGroup].images[currentIndex]);
GROUPS[activeGroup].sliderElements.forEach((slide, index) => {
setImageDimension(slide, GROUPS[activeGroup].images[index]);
});
updateOffset();

@@ -960,4 +964,4 @@ resizeTicking = false;

const captionRec = slideEl.querySelector('.parvus__caption') !== null ? slideEl.querySelector('.parvus__caption').getBoundingClientRect().height : 0;
const srcHeight = imageEl.naturalHeight;
const srcWidth = imageEl.naturalWidth;
const srcHeight = imageEl.getAttribute('height');
const srcWidth = imageEl.getAttribute('width');
let maxHeight = slideEl.getBoundingClientRect().height;

@@ -967,11 +971,13 @@ let maxWidth = slideEl.getBoundingClientRect().width;

maxWidth -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
const ratio = Math.min(maxWidth / srcWidth || 0, maxHeight / srcHeight);
const newWidth = srcWidth * ratio || 0;
const newHeight = srcHeight * ratio || 0;
if (imageEl.naturalHeight < maxHeight && imageEl.naturalWidth < maxWidth) {
maxHeight = imageEl.naturalHeight;
maxWidth = imageEl.naturalWidth;
if (srcHeight > newHeight && srcHeight < maxHeight && srcWidth > newWidth && srcWidth < maxWidth || srcHeight < newHeight && srcHeight < maxHeight && srcWidth < newWidth && srcWidth < maxWidth) {
imageEl.style.width = '';
imageEl.style.height = '';
} else {
imageEl.style.width = `${newWidth}px`;
imageEl.style.height = `${newHeight}px`;
}
const ratio = Math.min(maxWidth / srcWidth || 0, maxHeight / srcHeight);
imageEl.style.width = `${srcWidth * ratio || 0}px`;
imageEl.style.height = `${srcHeight * ratio || 0}px`;
};

@@ -1013,3 +1019,3 @@ /**

const getFocusableChildren = function getFocusableChildren() {
return Array.prototype.slice.call(lightbox.querySelectorAll(`${FOCUSABLE_ELEMENTS.join(', ')}`)).filter(function (child) {
return Array.prototype.slice.call(lightbox.querySelectorAll(`${FOCUSABLE_ELEMENTS.join(', ')}`)).filter(child => {
return !!(child.offsetWidth || child.offsetHeight || child.getClientRects().length);

@@ -1087,4 +1093,4 @@ });

drag.startY = event.pageY;
groups[activeGroup].slider.classList.add('parvus__slider--is-dragging');
groups[activeGroup].slider.style.willChange = 'transform';
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-dragging');
GROUPS[activeGroup].slider.style.willChange = 'transform';
};

@@ -1115,4 +1121,4 @@ /**

pointerDown = false;
groups[activeGroup].slider.classList.remove('parvus__slider--is-dragging');
groups[activeGroup].slider.style.willChange = 'auto';
GROUPS[activeGroup].slider.classList.remove('parvus__slider--is-dragging');
GROUPS[activeGroup].slider.style.willChange = 'auto';

@@ -1138,4 +1144,4 @@ if (drag.endX || drag.endY) {

drag.startY = event.touches[0].pageY;
groups[activeGroup].slider.classList.add('parvus__slider--is-dragging');
groups[activeGroup].slider.style.willChange = 'transform';
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-dragging');
GROUPS[activeGroup].slider.style.willChange = 'transform';
};

@@ -1167,4 +1173,4 @@ /**

pointerDown = false;
groups[activeGroup].slider.classList.remove('parvus__slider--is-dragging');
groups[activeGroup].slider.style.willChange = 'auto';
GROUPS[activeGroup].slider.classList.remove('parvus__slider--is-dragging');
GROUPS[activeGroup].slider.style.willChange = 'auto';

@@ -1188,5 +1194,5 @@ if (drag.endX || drag.endY) {

if (Math.abs(MOVEMENT_X) > 0 && !isDraggingY && groups[activeGroup].gallery.length > 1) {
if (Math.abs(MOVEMENT_X) > 0 && !isDraggingY && GROUPS[activeGroup].gallery.length > 1) {
// Horizontal swipe
groups[activeGroup].slider.style.transform = `translate3d(${offsetTmp - Math.round(MOVEMENT_X)}px, 0, 0)`;
GROUPS[activeGroup].slider.style.transform = `translate3d(${offsetTmp - Math.round(MOVEMENT_X)}px, 0, 0)`;
isDraggingX = true;

@@ -1203,3 +1209,3 @@ isDraggingY = false;

lightboxOverlay.style.opacity = lightboxOverlayOpacity;
groups[activeGroup].slider.style.transform = `translate3d(${offsetTmp}px, ${Math.round(MOVEMENT_Y)}px, 0)`;
GROUPS[activeGroup].slider.style.transform = `translate3d(${offsetTmp}px, ${Math.round(MOVEMENT_Y)}px, 0)`;
isDraggingX = false;

@@ -1206,0 +1212,0 @@ isDraggingY = true;

@@ -5,3 +5,3 @@ /**

* @author Benjamin de Oostfrees
* @version 2.0.3
* @version 2.0.4
* @url https://github.com/deoostfrees/parvus

@@ -12,2 +12,2 @@ *

var e={lightboxLabel:"This is a dialog window which overlays the main content of the page. The modal shows the enlarged image. Pressing the Escape key will close the modal and bring you back to where you were on the page.",lightboxLoadingIndicatorLabel:"Image loading",previousButtonLabel:"Previous image",nextButtonLabel:"Next image",closeButtonLabel:"Close dialog window"};function t(n){const i=window,a=["button:not([disabled]):not([inert])",'[tabindex]:not([tabindex^="-"]):not([inert])'],s={gallery:[],slider:null,sliderElements:[],images:[]};let r={},l=null,o=null,d=0,u={},c=null,p=null,g=1,h=null,m=null,v=null,f=null,b=null,y=null,w=null,E=0,A=0,L=0,_=0,C={},x=!1,$=!1,S=!1,B=null,T=null,M=null,q=!1,F=null,I=!0;const N=window.matchMedia("(prefers-reduced-motion)"),X=function(){N.matches?(I=!0,F=u.reducedTransitionDuration):(I=!1,F=u.transitionDuration)};N.addEventListener("change",X);const Y=function(t){u=function(t){return{selector:".lightbox",gallerySelector:null,captions:!0,captionsSelector:"self",captionsAttribute:"data-caption",docClose:!0,scrollClose:!1,swipeClose:!0,threshold:50,backFocus:!0,transitionDuration:300,reducedTransitionDuration:.1,transitionTimingFunction:"cubic-bezier(0.4, 0, 0.22, 1)",lightboxIndicatorIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"/></svg>',previousButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>',nextButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>',closeButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18M6 6l12 12"/></svg>',l10n:e,fileTypes:/\.(png|jpe?g|webp|avif|svg)(\?.*)?$/i,...t}}(t);if(document.querySelectorAll(u.selector).length)if(X(),c||O(),null!==u.gallerySelector){document.querySelectorAll(u.gallerySelector).forEach(((e,t)=>{const n=t;e.querySelectorAll(u.selector).forEach((e=>{e.setAttribute("data-group",`parvus-gallery-${n}`),H(e)}))}));document.querySelectorAll(`${u.selector}:not(.parvus-trigger)`).forEach((e=>{H(e)}))}else{document.querySelectorAll(u.selector).forEach((e=>{H(e)}))}},k=function(e){const t=Math.floor(1e4*Math.random());return e.hasAttribute("data-group")&&""!==e.getAttribute("data-group")||e.setAttribute("data-group",`default-${t}`),e.getAttribute("data-group")},H=function(e){if(!("A"===e.tagName&&e.hasAttribute("href")&&e.href.match(u.fileTypes)||"BUTTON"===e.tagName&&e.hasAttribute("data-target")&&e.getAttribute("data-target").match(u.fileTypes)))throw new Error(e,`Use a link with the 'href' attribute or a button with the 'data-target' attribute. Both attributes must have a path to the image file. Supported image file types: ${u.fileTypes}.`);var t;if(l=k(e),Object.prototype.hasOwnProperty.call(r,l)||(r[l]=(t=s,JSON.parse(JSON.stringify(t)))),r[l].gallery.includes(e))throw new Error("Ups, element already added.");if(r[l].gallery.push(e),null!==e.querySelector("img")){const t=document.createElement("div");e.classList.add("parvus-zoom"),t.className="parvus-zoom__indicator",t.innerHTML=u.lightboxIndicatorIcon,e.appendChild(t)}e.classList.add("parvus-trigger"),e.addEventListener("click",le),Ae()&&l===o&&(z(e,r[l].gallery.indexOf(e)),j(e,r[l].gallery.indexOf(e),(function(){J(r[l].gallery.indexOf(e))})),ae(),ee(),te())},D=function(e){if(Ae()||!c||!e||!e.hasAttribute("data-group"))return;const t=k(e);if(!r[t].gallery.includes(e))throw new Error("Ups, I can't find the element.");if(r[t].gallery.splice(r[t].gallery.indexOf(e),1),e.classList.contains("parvus-zoom")){const t=e.querySelector(".parvus-zoom__indicator");e.classList.remove("parvus-zoom"),e.removeChild(t)}e.removeEventListener("click",le),e.classList.remove("parvus-trigger")},O=function(){c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-hidden","true"),c.setAttribute("tabindex","-1"),c.setAttribute("aria-label",u.l10n.lightboxLabel),c.classList.add("parvus"),p=document.createElement("div"),p.classList.add("parvus__overlay"),p.style.opacity=0,c.appendChild(p),h=document.createElement("div"),h.className="parvus__toolbar",m=document.createElement("div"),v=document.createElement("div"),y=document.createElement("button"),y.className="parvus__btn parvus__btn--close",y.setAttribute("type","button"),y.setAttribute("aria-label",u.l10n.closeButtonLabel),y.innerHTML=u.closeButtonIcon,v.appendChild(y),f=document.createElement("button"),f.className="parvus__btn parvus__btn--previous",f.setAttribute("type","button"),f.setAttribute("aria-label",u.l10n.previousButtonLabel),f.innerHTML=u.previousButtonIcon,c.appendChild(f),b=document.createElement("button"),b.className="parvus__btn parvus__btn--next",b.setAttribute("type","button"),b.setAttribute("aria-label",u.l10n.nextButtonLabel),b.innerHTML=u.nextButtonIcon,c.appendChild(b),w=document.createElement("div"),w.className="parvus__counter",m.appendChild(w),h.appendChild(m),h.appendChild(v),c.appendChild(h),document.body.appendChild(c)},z=function(e,t){if(void 0!==r[o].sliderElements[t]);else{const e=document.createElement("div"),n=document.createElement("div");e.className="parvus__slide",e.style.position="absolute",e.style.left=100*t+"%",e.setAttribute("aria-hidden","true"),e.appendChild(n),r[o].sliderElements[t]=e,t===d&&r[o].slider.appendChild(e),t>d?r[o].sliderElements[d].after(e):r[o].sliderElements[d].before(e)}},R=function(e){if(!c||!e||!e.classList.contains("parvus-trigger")||Ae())return;if(o=k(e),!r[o].gallery.includes(e))throw new Error("Ups, I can't find the element.");d=r[o].gallery.indexOf(e),B=document.activeElement;const t=window.location.href;history.pushState({parvus:"close"},"Image",t),we();document.querySelectorAll('body > *:not([aria-hidden="true"])').forEach((e=>{e.setAttribute("aria-hidden","true"),e.classList.add("parvus-hidden")})),c.classList.add("parvus--is-opening"),c.setAttribute("aria-hidden","false"),r[o].slider=document.createElement("div"),r[o].slider.className="parvus__slider",r[o].slider.setAttribute("aria-hidden","true"),c.appendChild(r[o].slider),z(e,d),r[o].slider.setAttribute("aria-hidden","false"),Z(),ae(),te(),ue(),W(d),j(e,d,(function(){J(d),requestAnimationFrame((()=>{c.classList.remove("parvus--is-opening"),p.style.opacity=1,p.style.transition=`opacity ${F}ms ${u.transitionTimingFunction}`,p.style.willChange="opacity"})),p.addEventListener("transitionend",(()=>{P(d+1),P(d-1)})),r[o].slider.classList.add("parvus__slider--animate")}));const n=new CustomEvent("open",{detail:{source:e}});c.dispatchEvent(n)},U=function(){if(!Ae())throw new Error("Ups, I'm already closed.");const e=r[o].images[d],t=e.getBoundingClientRect(),n=(u.backFocus?r[o].gallery[d]:B).getBoundingClientRect();Ee(),ne(),null!==history.state&&"close"===history.state.parvus&&history.back();document.querySelectorAll(".parvus-hidden").forEach((e=>{e.removeAttribute("aria-hidden"),e.classList.remove("parvus-hidden")})),c.classList.add("parvus--is-closing"),requestAnimationFrame((()=>{E=n.width/t.width,A=n.height/t.height,L=n.left-t.left,_=n.top-t.top,e.style.transform=`translate(${L}px, ${_}px) scale(${E}, ${A})`,e.style.opacity=0,e.style.transition=`transform ${F}ms ${u.transitionTimingFunction}, opacity ${F}ms ${u.transitionTimingFunction} ${F/2}ms`,p.style.opacity=0,p.style.transition=`opacity ${F}ms ${u.transitionTimingFunction}`,p.style.willChange="auto"})),p.addEventListener("transitionend",(()=>{Q(d),B=u.backFocus?r[o].gallery[d]:B,B.focus({preventScroll:!0}),c.setAttribute("aria-hidden","true"),c.classList.remove("parvus--is-closing"),c.classList.remove("parvus--is-vertical-closing"),e.style.transform="",r[o].slider.remove(),r[o].slider=null,r[o].sliderElements=[],r[o].images=[]}),{once:!0});const i=new CustomEvent("close",{detail:{source:r[o].gallery[d]}});c.dispatchEvent(i)},P=function(e){void 0!==r[o].gallery[e]&&(z(r[o].gallery[e],e),j(r[o].gallery[e],e,(function(){J(e)})))},W=function(e){r[o].sliderElements[e].classList.add("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","false")},j=function(e,t,n){if(void 0!==r[o].images[t]);else{const i=r[o].sliderElements[t].querySelector("div"),a=document.createElement("img"),s=document.createElement("div"),l=document.createElement("div"),d=e.querySelector("img"),c=document.createElement("div");if(s.className="parvus__content",l.className="parvus__caption",c.className="parvus__loader",c.setAttribute("role","progressbar"),c.setAttribute("aria-label",u.l10n.lightboxLoadingIndicatorLabel),i.appendChild(c),a.onload=()=>{i.removeChild(c),a.setAttribute("width",a.naturalWidth),a.setAttribute("height",a.naturalHeight),re(r[o].sliderElements[t],a),n&&"function"==typeof n&&n()},"A"===e.tagName?(a.setAttribute("src",e.href),a.alt=d?d.alt||"":e.getAttribute("data-alt")||""):(a.alt=e.getAttribute("data-alt")||"",a.setAttribute("src",e.getAttribute("data-target"))),e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&a.setAttribute("srcset",e.getAttribute("data-srcset")),a.style.opacity=0,s.appendChild(a),r[o].images[t]=a,i.appendChild(s),u.captions){let t=null;if("self"===u.captionsSelector)e.hasAttribute(u.captionsAttribute)&&""!==e.getAttribute(u.captionsAttribute)&&(t=e.getAttribute(u.captionsAttribute));else if(null!==e.querySelector(u.captionsSelector)){const n=e.querySelector(u.captionsSelector);t=n.hasAttribute(u.captionsAttribute)&&""!==n.getAttribute(u.captionsAttribute)?n.getAttribute(u.captionsAttribute):n.innerHTML}null!==t&&(l.innerHTML=`<p>${t}</p>`,i.appendChild(l))}}},J=function(e){const t=r[o].images[e],n=t.getBoundingClientRect(),i=r[o].gallery[e].getBoundingClientRect();c.classList.contains("parvus--is-opening")?(E=i.width/n.width,A=i.height/n.height,L=i.left-n.left,_=i.top-n.top,requestAnimationFrame((()=>{t.style.transform=`translate(${L}px, ${_}px) scale(${E}, ${A})`,t.style.transition="transform 0s, opacity 0s",requestAnimationFrame((()=>{t.style.transform="",t.style.opacity=1,t.style.transition=`transform ${F}ms ${u.transitionTimingFunction}, opacity ${F/2}ms ${u.transitionTimingFunction}`}))}))):t.style.opacity=1},K=function(e){const t=d;if(!Ae())throw new Error("Ups, I'm closed.");if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===d)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=r[o].gallery.length)throw new Error(`Ups, I can't find slide ${e}.`);Q(t),W(e),J(e),e<t&&(d--,Z(),ae(),ee("left"),P(e-1)),e>t&&(d++,Z(),ae(),ee("right"),P(e+1)),te();const n=new CustomEvent("select",{detail:{source:r[o].gallery[d]}});c.dispatchEvent(n)},V=function(){d>0&&K(d-1)},G=function(){d<r[o].gallery.length-1&&K(d+1)},Q=function(e){r[o].sliderElements[e].classList.remove("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","true")},Z=function(){o=null!==o?o:l,T=d*c.offsetWidth*-1,r[o].slider.style.transform=`translate3d(${T}px, 0, 0)`,M=T},ee=function(e){1===r[o].gallery.length?y.focus():0===d?b.focus():d===r[o].gallery.length-1||"left"===e?f.focus():b.focus()},te=function(){w.textContent=`${d+1}/${r[o].gallery.length}`},ne=function(){C={startX:0,endX:0,startY:0,endY:0}},ie=function(){const e=C.endX-C.startX,t=C.endY-C.startY,n=Math.abs(e),i=Math.abs(t);x&&e>0&&n>=u.threshold&&d>0?V():x&&e<0&&n>=u.threshold&&d!==r[o].gallery.length-1?G():$&&i>0?i>=u.threshold&&u.swipeClose?U():(p.style.opacity=1,c.classList.remove("parvus--is-vertical-closing"),Z()):Z()},ae=function(){(u.swipeClose&&!r[o].slider.classList.contains("parvus__slider--is-draggable")||r[o].gallery.length>1&&!r[o].slider.classList.contains("parvus__slider--is-draggable"))&&r[o].slider.classList.add("parvus__slider--is-draggable"),1===r[o].gallery.length?(f.setAttribute("aria-hidden","true"),f.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0):0===d?(f.setAttribute("aria-hidden","true"),f.disabled=!0,b.setAttribute("aria-hidden","false"),b.disabled=!1):d===r[o].gallery.length-1?(f.setAttribute("aria-hidden","false"),f.disabled=!1,b.setAttribute("aria-hidden","true"),b.disabled=!0):(f.setAttribute("aria-hidden","false"),f.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1),1===r[o].gallery.length?w.setAttribute("aria-hidden","true"):w.setAttribute("aria-hidden","false")},se=function(){q||(q=!0,i.requestAnimationFrame((()=>{re(r[o].sliderElements[d],r[o].images[d]),Z(),q=!1})))},re=function(e,t){const n=getComputedStyle(e),i=null!==e.querySelector(".parvus__caption")?e.querySelector(".parvus__caption").getBoundingClientRect().height:0,a=t.naturalHeight,s=t.naturalWidth;let r=e.getBoundingClientRect().height,l=e.getBoundingClientRect().width;r-=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)+parseFloat(i),l-=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight),t.naturalHeight<r&&t.naturalWidth<l&&(r=t.naturalHeight,l=t.naturalWidth);const o=Math.min(l/s||0,r/a);t.style.width=`${s*o||0}px`,t.style.height=`${a*o||0}px`},le=function(e){e.preventDefault(),R(this)},oe=function(e){e.target===f?V():e.target===b?G():(e.target===y||!$&&!x&&e.target.classList.contains("parvus__slide")&&u.docClose)&&U(),e.stopPropagation()},de=function(){return Array.prototype.slice.call(c.querySelectorAll(`${a.join(", ")}`)).filter((function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}))},ue=function(){de()[0].focus()},ce=function(e){const t=de(),n=t.indexOf(document.activeElement);"Tab"===e.code?e.shiftKey&&0===n?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||n!==t.length-1||(t[0].focus(),e.preventDefault()):"Escape"===e.code?(e.preventDefault(),U()):"ArrowLeft"===e.code?(e.preventDefault(),V()):"ArrowRight"===e.code&&(e.preventDefault(),G())},pe=function(){U()},ge=function(e){e.preventDefault(),e.stopPropagation(),x=!1,$=!1,S=!0,C.startX=e.pageX,C.startY=e.pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},he=function(e){e.preventDefault(),S&&(C.endX=e.pageX,C.endY=e.pageY,ye())},me=function(e){e.stopPropagation(),S=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(C.endX||C.endY)&&ie(),ne()},ve=function(e){e.stopPropagation(),x=!1,$=!1,S=!0,C.startX=e.touches[0].pageX,C.startY=e.touches[0].pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},fe=function(e){e.stopPropagation(),S&&(e.preventDefault(),C.endX=e.touches[0].pageX,C.endY=e.touches[0].pageY,ye())},be=function(e){e.stopPropagation(),S=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(C.endX||C.endY)&&ie(),ne()},ye=function(){const e=C.startX-C.endX,t=C.endY-C.startY,n=Math.abs(t);Math.abs(e)>0&&!$&&r[o].gallery.length>1?(r[o].slider.style.transform=`translate3d(${M-Math.round(e)}px, 0, 0)`,x=!0,$=!1):Math.abs(t)>0&&!x&&u.swipeClose&&(n<=96&&!I&&(g=1-n/100),c.classList.add("parvus--is-vertical-closing"),p.style.opacity=g,r[o].slider.style.transform=`translate3d(${M}px, ${Math.round(t)}px, 0)`,x=!1,$=!0)},we=function(){i.addEventListener("keydown",ce),i.addEventListener("resize",se),u.scrollClose&&i.addEventListener("wheel",pe),i.addEventListener("popstate",U),c.addEventListener("click",oe),Le()&&(c.addEventListener("touchstart",ve),c.addEventListener("touchmove",fe),c.addEventListener("touchend",be)),c.addEventListener("mousedown",ge),c.addEventListener("mouseup",me),c.addEventListener("mousemove",he)},Ee=function(){i.removeEventListener("keydown",ce),i.removeEventListener("resize",se),u.scrollClose&&i.removeEventListener("wheel",pe),i.removeEventListener("popstate",U),c.removeEventListener("click",oe),Le()&&(c.removeEventListener("touchstart",ve),c.removeEventListener("touchmove",fe),c.removeEventListener("touchend",be)),c.removeEventListener("mousedown",ge),c.removeEventListener("mouseup",me),c.removeEventListener("mousemove",he)},Ae=function(){return"false"===c.getAttribute("aria-hidden")},Le=function(){return"ontouchstart"in window};return Y(n),t.init=Y,t.open=R,t.close=U,t.select=K,t.previous=V,t.next=G,t.currentIndex=function(){return d},t.add=H,t.remove=D,t.destroy=function(){if(!c)return;Ae()&&U(),c.remove();document.querySelectorAll(".parvus-trigger").forEach((e=>{D(e)}));const e=new CustomEvent("destroy");c.dispatchEvent(e)},t.isOpen=Ae,t.on=function(e,t){c&&c.addEventListener(e,t)},t.off=function(e,t){c&&c.removeEventListener(e,t)},t}export{t as default};
var e={lightboxLabel:"This is a dialog window which overlays the main content of the page. The modal shows the enlarged image. Pressing the Escape key will close the modal and bring you back to where you were on the page.",lightboxLoadingIndicatorLabel:"Image loading",previousButtonLabel:"Previous image",nextButtonLabel:"Next image",closeButtonLabel:"Close dialog window"};function t(n){const i=window,s=["button:not([disabled]):not([inert])",'[tabindex]:not([tabindex^="-"]):not([inert])'],a={gallery:[],slider:null,sliderElements:[],images:[]},r={};let l=null,o=null,d=0,u={},c=null,p=null,g=1,h=null,m=null,v=null,f=null,b=null,y=null,w=null,E=0,A=0,L=0,_=0,C={},x=!1,$=!1,S=!1,B=null,T=null,M=null,q=!1,F=null,I=!0;const N=window.matchMedia("(prefers-reduced-motion)"),X=function(){N.matches?(I=!0,F=u.reducedTransitionDuration):(I=!1,F=u.transitionDuration)};N.addEventListener("change",X);const Y=function(t){u=function(t){return{selector:".lightbox",gallerySelector:null,captions:!0,captionsSelector:"self",captionsAttribute:"data-caption",docClose:!0,scrollClose:!1,swipeClose:!0,threshold:50,backFocus:!0,transitionDuration:300,reducedTransitionDuration:.1,transitionTimingFunction:"cubic-bezier(0.4, 0, 0.22, 1)",lightboxIndicatorIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"/></svg>',previousButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>',nextButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>',closeButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18M6 6l12 12"/></svg>',l10n:e,fileTypes:/\.(png|jpe?g|webp|avif|svg)(\?.*)?$/i,...t}}(t);if(document.querySelectorAll(u.selector).length)if(X(),c||H(),null!==u.gallerySelector){document.querySelectorAll(u.gallerySelector).forEach(((e,t)=>{const n=t;e.querySelectorAll(u.selector).forEach((e=>{e.setAttribute("data-group",`parvus-gallery-${n}`),D(e)}))}));document.querySelectorAll(`${u.selector}:not(.parvus-trigger)`).forEach((e=>{D(e)}))}else{document.querySelectorAll(u.selector).forEach((e=>{D(e)}))}},k=function(e){const t=Math.floor(1e4*Math.random());return e.hasAttribute("data-group")&&""!==e.getAttribute("data-group")||e.setAttribute("data-group",`default-${t}`),e.getAttribute("data-group")},D=function(e){if(!("A"===e.tagName&&e.hasAttribute("href")&&e.href.match(u.fileTypes)||"BUTTON"===e.tagName&&e.hasAttribute("data-target")&&e.getAttribute("data-target").match(u.fileTypes)))throw new Error(e,`Use a link with the 'href' attribute or a button with the 'data-target' attribute. Both attributes must have a path to the image file. Supported image file types: ${u.fileTypes}.`);var t;if(l=k(e),Object.prototype.hasOwnProperty.call(r,l)||(r[l]=(t=a,JSON.parse(JSON.stringify(t)))),r[l].gallery.includes(e))throw new Error("Ups, element already added.");if(r[l].gallery.push(e),null!==e.querySelector("img")){const t=document.createElement("div");e.classList.add("parvus-zoom"),t.className="parvus-zoom__indicator",t.innerHTML=u.lightboxIndicatorIcon,e.appendChild(t)}e.classList.add("parvus-trigger"),e.addEventListener("click",le),Ae()&&l===o&&(z(r[l].gallery.indexOf(e)),W(e,r[l].gallery.indexOf(e),(function(){J(r[l].gallery.indexOf(e))})),se(),ee(),te())},O=function(e){if(Ae()||!c||!e||!e.hasAttribute("data-group"))return;const t=k(e);if(!r[t].gallery.includes(e))throw new Error("Ups, I can't find the element.");if(r[t].gallery.splice(r[t].gallery.indexOf(e),1),e.classList.contains("parvus-zoom")){const t=e.querySelector(".parvus-zoom__indicator");e.classList.remove("parvus-zoom"),e.removeChild(t)}e.removeEventListener("click",le),e.classList.remove("parvus-trigger")},H=function(){c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-hidden","true"),c.setAttribute("tabindex","-1"),c.setAttribute("aria-label",u.l10n.lightboxLabel),c.classList.add("parvus"),p=document.createElement("div"),p.classList.add("parvus__overlay"),p.style.opacity=0,c.appendChild(p),h=document.createElement("div"),h.className="parvus__toolbar",m=document.createElement("div"),v=document.createElement("div"),y=document.createElement("button"),y.className="parvus__btn parvus__btn--close",y.setAttribute("type","button"),y.setAttribute("aria-label",u.l10n.closeButtonLabel),y.innerHTML=u.closeButtonIcon,v.appendChild(y),f=document.createElement("button"),f.className="parvus__btn parvus__btn--previous",f.setAttribute("type","button"),f.setAttribute("aria-label",u.l10n.previousButtonLabel),f.innerHTML=u.previousButtonIcon,c.appendChild(f),b=document.createElement("button"),b.className="parvus__btn parvus__btn--next",b.setAttribute("type","button"),b.setAttribute("aria-label",u.l10n.nextButtonLabel),b.innerHTML=u.nextButtonIcon,c.appendChild(b),w=document.createElement("div"),w.className="parvus__counter",m.appendChild(w),h.appendChild(m),h.appendChild(v),c.appendChild(h),document.body.appendChild(c)},z=function(e){if(void 0!==r[o].sliderElements[e]);else{const t=document.createElement("div"),n=document.createElement("div");t.className="parvus__slide",t.style.position="absolute",t.style.left=100*e+"%",t.setAttribute("aria-hidden","true"),t.appendChild(n),r[o].sliderElements[e]=t,e===d&&r[o].slider.appendChild(t),e>d?r[o].sliderElements[d].after(t):r[o].sliderElements[d].before(t)}},R=function(e){if(!c||!e||!e.classList.contains("parvus-trigger")||Ae())return;if(o=k(e),!r[o].gallery.includes(e))throw new Error("Ups, I can't find the element.");d=r[o].gallery.indexOf(e),B=document.activeElement;const t=window.location.href;history.pushState({parvus:"close"},"Image",t),we();document.querySelectorAll('body > *:not([aria-hidden="true"])').forEach((e=>{e.setAttribute("aria-hidden","true"),e.classList.add("parvus-hidden")})),c.classList.add("parvus--is-opening"),c.setAttribute("aria-hidden","false"),r[o].slider=document.createElement("div"),r[o].slider.className="parvus__slider",r[o].slider.setAttribute("aria-hidden","true"),c.appendChild(r[o].slider),z(d),r[o].slider.setAttribute("aria-hidden","false"),Z(),se(),te(),ue(),j(d),W(e,d,(function(){J(d),requestAnimationFrame((()=>{c.classList.remove("parvus--is-opening"),p.style.opacity=1,p.style.transition=`opacity ${F}ms ${u.transitionTimingFunction}`,p.style.willChange="opacity"})),p.addEventListener("transitionend",(()=>{P(d+1),P(d-1)})),r[o].slider.classList.add("parvus__slider--animate")}));const n=new CustomEvent("open",{detail:{source:e}});c.dispatchEvent(n)},U=function(){if(!Ae())throw new Error("Ups, I'm already closed.");const e=r[o].images[d],t=e.getBoundingClientRect(),n=(u.backFocus?r[o].gallery[d]:B).getBoundingClientRect();Ee(),ne(),null!==history.state&&"close"===history.state.parvus&&history.back();document.querySelectorAll(".parvus-hidden").forEach((e=>{e.removeAttribute("aria-hidden"),e.classList.remove("parvus-hidden")})),c.classList.add("parvus--is-closing"),requestAnimationFrame((()=>{E=n.width/t.width,A=n.height/t.height,L=n.left-t.left,_=n.top-t.top,e.style.transform=`translate(${L}px, ${_}px) scale(${E}, ${A})`,e.style.opacity=0,e.style.transition=`transform ${F}ms ${u.transitionTimingFunction}, opacity ${F}ms ${u.transitionTimingFunction} ${F/2}ms`,p.style.opacity=0,p.style.transition=`opacity ${F}ms ${u.transitionTimingFunction}`,p.style.willChange="auto"})),p.addEventListener("transitionend",(()=>{Q(d),B=u.backFocus?r[o].gallery[d]:B,B.focus({preventScroll:!0}),c.setAttribute("aria-hidden","true"),c.classList.remove("parvus--is-closing"),c.classList.remove("parvus--is-vertical-closing"),e.style.transform="",r[o].slider.remove(),r[o].slider=null,r[o].sliderElements=[],r[o].images=[]}),{once:!0});const i=new CustomEvent("close",{detail:{source:r[o].gallery[d]}});c.dispatchEvent(i)},P=function(e){void 0!==r[o].gallery[e]&&(z(e),W(r[o].gallery[e],e,(function(){J(e)})))},j=function(e){r[o].sliderElements[e].classList.add("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","false")},W=function(e,t,n){if(void 0!==r[o].images[t]);else{const i=r[o].sliderElements[t].querySelector("div"),s=document.createElement("img"),a=document.createElement("div"),l=document.createElement("div"),d=e.querySelector("img"),c=document.createElement("div");if(a.className="parvus__content",l.className="parvus__caption",c.className="parvus__loader",c.setAttribute("role","progressbar"),c.setAttribute("aria-label",u.l10n.lightboxLoadingIndicatorLabel),i.appendChild(c),s.onload=()=>{i.removeChild(c),s.setAttribute("width",s.naturalWidth),s.setAttribute("height",s.naturalHeight),re(r[o].sliderElements[t],s),n&&"function"==typeof n&&n()},"A"===e.tagName?(s.setAttribute("src",e.href),s.alt=d?d.alt||"":e.getAttribute("data-alt")||""):(s.alt=e.getAttribute("data-alt")||"",s.setAttribute("src",e.getAttribute("data-target"))),e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&s.setAttribute("srcset",e.getAttribute("data-srcset")),s.style.opacity=0,a.appendChild(s),r[o].images[t]=s,i.appendChild(a),u.captions){let n=null;if("self"===u.captionsSelector)e.hasAttribute(u.captionsAttribute)&&""!==e.getAttribute(u.captionsAttribute)&&(n=e.getAttribute(u.captionsAttribute));else if(null!==e.querySelector(u.captionsSelector)){const t=e.querySelector(u.captionsSelector);n=t.hasAttribute(u.captionsAttribute)&&""!==t.getAttribute(u.captionsAttribute)?t.getAttribute(u.captionsAttribute):t.innerHTML}null!==n&&(r[o].sliderElements[t].setAttribute("aria-labelledby",`parvus__caption-${t}`),l.id=`parvus__caption-${t}`,l.innerHTML=`<p>${n}</p>`,i.appendChild(l))}}},J=function(e){const t=r[o].images[e],n=t.getBoundingClientRect(),i=r[o].gallery[e].getBoundingClientRect();c.classList.contains("parvus--is-opening")?(E=i.width/n.width,A=i.height/n.height,L=i.left-n.left,_=i.top-n.top,requestAnimationFrame((()=>{t.style.transform=`translate(${L}px, ${_}px) scale(${E}, ${A})`,t.style.transition="transform 0s, opacity 0s",requestAnimationFrame((()=>{t.style.transform="",t.style.opacity=1,t.style.transition=`transform ${F}ms ${u.transitionTimingFunction}, opacity ${F/2}ms ${u.transitionTimingFunction}`}))}))):t.style.opacity=1},K=function(e){const t=d;if(!Ae())throw new Error("Ups, I'm closed.");if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===d)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=r[o].gallery.length)throw new Error(`Ups, I can't find slide ${e}.`);Q(t),j(e),J(e),e<t&&(d--,Z(),se(),ee("left"),P(e-1)),e>t&&(d++,Z(),se(),ee("right"),P(e+1)),te();const n=new CustomEvent("select",{detail:{source:r[o].gallery[d]}});c.dispatchEvent(n)},V=function(){d>0&&K(d-1)},G=function(){d<r[o].gallery.length-1&&K(d+1)},Q=function(e){r[o].sliderElements[e].classList.remove("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","true")},Z=function(){o=null!==o?o:l,T=d*c.offsetWidth*-1,r[o].slider.style.transform=`translate3d(${T}px, 0, 0)`,M=T},ee=function(e){1===r[o].gallery.length?y.focus():0===d?b.focus():d===r[o].gallery.length-1||"left"===e?f.focus():b.focus()},te=function(){w.textContent=`${d+1}/${r[o].gallery.length}`},ne=function(){C={startX:0,endX:0,startY:0,endY:0}},ie=function(){const e=C.endX-C.startX,t=C.endY-C.startY,n=Math.abs(e),i=Math.abs(t);x&&e>0&&n>=u.threshold&&d>0?V():x&&e<0&&n>=u.threshold&&d!==r[o].gallery.length-1?G():$&&i>0?i>=u.threshold&&u.swipeClose?U():(p.style.opacity=1,c.classList.remove("parvus--is-vertical-closing"),Z()):Z()},se=function(){(u.swipeClose&&!r[o].slider.classList.contains("parvus__slider--is-draggable")||r[o].gallery.length>1&&!r[o].slider.classList.contains("parvus__slider--is-draggable"))&&r[o].slider.classList.add("parvus__slider--is-draggable"),1===r[o].gallery.length?(f.setAttribute("aria-hidden","true"),f.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0):0===d?(f.setAttribute("aria-hidden","true"),f.disabled=!0,b.setAttribute("aria-hidden","false"),b.disabled=!1):d===r[o].gallery.length-1?(f.setAttribute("aria-hidden","false"),f.disabled=!1,b.setAttribute("aria-hidden","true"),b.disabled=!0):(f.setAttribute("aria-hidden","false"),f.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1),1===r[o].gallery.length?w.setAttribute("aria-hidden","true"):w.setAttribute("aria-hidden","false")},ae=function(){q||(q=!0,i.requestAnimationFrame((()=>{r[o].sliderElements.forEach(((e,t)=>{re(e,r[o].images[t])})),Z(),q=!1})))},re=function(e,t){const n=getComputedStyle(e),i=null!==e.querySelector(".parvus__caption")?e.querySelector(".parvus__caption").getBoundingClientRect().height:0,s=t.getAttribute("height"),a=t.getAttribute("width");let r=e.getBoundingClientRect().height,l=e.getBoundingClientRect().width;r-=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)+parseFloat(i),l-=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight);const o=Math.min(l/a||0,r/s),d=a*o||0,u=s*o||0;s>u&&s<r&&a>d&&a<l||s<u&&s<r&&a<d&&a<l?(t.style.width="",t.style.height=""):(t.style.width=`${d}px`,t.style.height=`${u}px`)},le=function(e){e.preventDefault(),R(this)},oe=function(e){e.target===f?V():e.target===b?G():(e.target===y||!$&&!x&&e.target.classList.contains("parvus__slide")&&u.docClose)&&U(),e.stopPropagation()},de=function(){return Array.prototype.slice.call(c.querySelectorAll(`${s.join(", ")}`)).filter((e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)))},ue=function(){de()[0].focus()},ce=function(e){const t=de(),n=t.indexOf(document.activeElement);"Tab"===e.code?e.shiftKey&&0===n?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||n!==t.length-1||(t[0].focus(),e.preventDefault()):"Escape"===e.code?(e.preventDefault(),U()):"ArrowLeft"===e.code?(e.preventDefault(),V()):"ArrowRight"===e.code&&(e.preventDefault(),G())},pe=function(){U()},ge=function(e){e.preventDefault(),e.stopPropagation(),x=!1,$=!1,S=!0,C.startX=e.pageX,C.startY=e.pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},he=function(e){e.preventDefault(),S&&(C.endX=e.pageX,C.endY=e.pageY,ye())},me=function(e){e.stopPropagation(),S=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(C.endX||C.endY)&&ie(),ne()},ve=function(e){e.stopPropagation(),x=!1,$=!1,S=!0,C.startX=e.touches[0].pageX,C.startY=e.touches[0].pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},fe=function(e){e.stopPropagation(),S&&(e.preventDefault(),C.endX=e.touches[0].pageX,C.endY=e.touches[0].pageY,ye())},be=function(e){e.stopPropagation(),S=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(C.endX||C.endY)&&ie(),ne()},ye=function(){const e=C.startX-C.endX,t=C.endY-C.startY,n=Math.abs(t);Math.abs(e)>0&&!$&&r[o].gallery.length>1?(r[o].slider.style.transform=`translate3d(${M-Math.round(e)}px, 0, 0)`,x=!0,$=!1):Math.abs(t)>0&&!x&&u.swipeClose&&(n<=96&&!I&&(g=1-n/100),c.classList.add("parvus--is-vertical-closing"),p.style.opacity=g,r[o].slider.style.transform=`translate3d(${M}px, ${Math.round(t)}px, 0)`,x=!1,$=!0)},we=function(){i.addEventListener("keydown",ce),i.addEventListener("resize",ae),u.scrollClose&&i.addEventListener("wheel",pe),i.addEventListener("popstate",U),c.addEventListener("click",oe),Le()&&(c.addEventListener("touchstart",ve),c.addEventListener("touchmove",fe),c.addEventListener("touchend",be)),c.addEventListener("mousedown",ge),c.addEventListener("mouseup",me),c.addEventListener("mousemove",he)},Ee=function(){i.removeEventListener("keydown",ce),i.removeEventListener("resize",ae),u.scrollClose&&i.removeEventListener("wheel",pe),i.removeEventListener("popstate",U),c.removeEventListener("click",oe),Le()&&(c.removeEventListener("touchstart",ve),c.removeEventListener("touchmove",fe),c.removeEventListener("touchend",be)),c.removeEventListener("mousedown",ge),c.removeEventListener("mouseup",me),c.removeEventListener("mousemove",he)},Ae=function(){return"false"===c.getAttribute("aria-hidden")},Le=function(){return"ontouchstart"in window};return Y(n),t.init=Y,t.open=R,t.close=U,t.select=K,t.previous=V,t.next=G,t.currentIndex=function(){return d},t.add=D,t.remove=O,t.destroy=function(){if(!c)return;Ae()&&U(),c.remove();document.querySelectorAll(".parvus-trigger").forEach((e=>{O(e)}));const e=new CustomEvent("destroy");c.dispatchEvent(e)},t.isOpen=Ae,t.on=function(e,t){c&&c.addEventListener(e,t)},t.off=function(e,t){c&&c.removeEventListener(e,t)},t}export{t as default};

@@ -5,3 +5,3 @@ /**

* @author Benjamin de Oostfrees
* @version 2.0.3
* @version 2.0.4
* @url https://github.com/deoostfrees/parvus

@@ -40,3 +40,3 @@ *

};
let groups = {};
const GROUPS = {};
let newGroup = null;

@@ -183,2 +183,3 @@ let activeGroup = null;

const getGroup = function getGroup(el) {
// Create a unique ID
const GROUP_ID = Math.floor(Math.random() * 10000);

@@ -217,9 +218,9 @@

if (!Object.prototype.hasOwnProperty.call(groups, newGroup)) {
groups[newGroup] = copyObject(GROUP_ATTS);
if (!Object.prototype.hasOwnProperty.call(GROUPS, newGroup)) {
GROUPS[newGroup] = copyObject(GROUP_ATTS);
} // Check if element already exists
if (!groups[newGroup].gallery.includes(el)) {
groups[newGroup].gallery.push(el);
if (!GROUPS[newGroup].gallery.includes(el)) {
GROUPS[newGroup].gallery.push(el);

@@ -239,5 +240,5 @@ if (el.querySelector('img') !== null) {

if (isOpen() && newGroup === activeGroup) {
createSlide(el, groups[newGroup].gallery.indexOf(el));
createImage(el, groups[newGroup].gallery.indexOf(el), function () {
loadImage(groups[newGroup].gallery.indexOf(el));
createSlide(GROUPS[newGroup].gallery.indexOf(el));
createImage(el, GROUPS[newGroup].gallery.indexOf(el), function () {
loadImage(GROUPS[newGroup].gallery.indexOf(el));
});

@@ -266,3 +267,3 @@ updateConfig();

if (!groups[GROUP].gallery.includes(el)) {
if (!GROUPS[GROUP].gallery.includes(el)) {
throw new Error('Ups, I can\'t find the element.');

@@ -272,3 +273,3 @@ } // TODO: Remove elements dynamically

groups[GROUP].gallery.splice(groups[GROUP].gallery.indexOf(el), 1); // Remove lightbox indicator icon if necessary
GROUPS[GROUP].gallery.splice(GROUPS[GROUP].gallery.indexOf(el), 1); // Remove lightbox indicator icon if necessary

@@ -355,7 +356,7 @@ if (el.classList.contains('parvus-zoom')) {

const createSlider = function createSlider() {
groups[activeGroup].slider = document.createElement('div');
groups[activeGroup].slider.className = 'parvus__slider'; // Hide slider
GROUPS[activeGroup].slider = document.createElement('div');
GROUPS[activeGroup].slider.className = 'parvus__slider'; // Hide slider
groups[activeGroup].slider.setAttribute('aria-hidden', 'true');
lightbox.appendChild(groups[activeGroup].slider);
GROUPS[activeGroup].slider.setAttribute('aria-hidden', 'true');
lightbox.appendChild(GROUPS[activeGroup].slider);
};

@@ -366,8 +367,7 @@ /**

* @param {HTMLElement} el
* @param {Number} index
*/
const createSlide = function createSlide(el, index) {
if (groups[activeGroup].sliderElements[index] !== undefined) ; else {
const createSlide = function createSlide(index) {
if (GROUPS[activeGroup].sliderElements[index] !== undefined) ; else {
const SLIDER_ELEMENT = document.createElement('div');

@@ -382,12 +382,12 @@ const SLIDER_ELEMENT_CONTENT = document.createElement('div');

SLIDER_ELEMENT.appendChild(SLIDER_ELEMENT_CONTENT);
groups[activeGroup].sliderElements[index] = SLIDER_ELEMENT; // Add slider element to slider
GROUPS[activeGroup].sliderElements[index] = SLIDER_ELEMENT; // Add slider element to slider
if (index === currentIndex) {
groups[activeGroup].slider.appendChild(SLIDER_ELEMENT);
GROUPS[activeGroup].slider.appendChild(SLIDER_ELEMENT);
}
if (index > currentIndex) {
groups[activeGroup].sliderElements[currentIndex].after(SLIDER_ELEMENT);
GROUPS[activeGroup].sliderElements[currentIndex].after(SLIDER_ELEMENT);
} else {
groups[activeGroup].sliderElements[currentIndex].before(SLIDER_ELEMENT);
GROUPS[activeGroup].sliderElements[currentIndex].before(SLIDER_ELEMENT);
}

@@ -410,7 +410,7 @@ }

if (!groups[activeGroup].gallery.includes(el)) {
if (!GROUPS[activeGroup].gallery.includes(el)) {
throw new Error('Ups, I can\'t find the element.');
}
currentIndex = groups[activeGroup].gallery.indexOf(el); // Save user’s focus
currentIndex = GROUPS[activeGroup].gallery.indexOf(el); // Save user’s focus

@@ -436,5 +436,5 @@ lastFocus = document.activeElement; // Use `history.pushState()` to make sure the 'Back' button behavior

createSlider();
createSlide(el, currentIndex); // Show slider
createSlide(currentIndex); // Show slider
groups[activeGroup].slider.setAttribute('aria-hidden', 'false');
GROUPS[activeGroup].slider.setAttribute('aria-hidden', 'false');
updateOffset();

@@ -459,3 +459,3 @@ updateConfig();

groups[activeGroup].slider.classList.add('parvus__slider--animate');
GROUPS[activeGroup].slider.classList.add('parvus__slider--animate');
}); // Create and dispatch a new event

@@ -481,5 +481,5 @@

const IMAGE = groups[activeGroup].images[currentIndex];
const IMAGE = GROUPS[activeGroup].images[currentIndex];
const IMAGE_SIZE = IMAGE.getBoundingClientRect();
const THUMBNAIL = config.backFocus ? groups[activeGroup].gallery[currentIndex] : lastFocus;
const THUMBNAIL = config.backFocus ? GROUPS[activeGroup].gallery[currentIndex] : lastFocus;
const THUMBNAIL_SIZE = THUMBNAIL.getBoundingClientRect();

@@ -518,3 +518,3 @@ unbindEvents();

lastFocus = config.backFocus ? groups[activeGroup].gallery[currentIndex] : lastFocus;
lastFocus = config.backFocus ? GROUPS[activeGroup].gallery[currentIndex] : lastFocus;
lastFocus.focus({

@@ -527,8 +527,8 @@ preventScroll: true

lightbox.classList.remove('parvus--is-vertical-closing');
IMAGE.style.transform = ''; // Reset groups
IMAGE.style.transform = ''; // Reset GROUPS
groups[activeGroup].slider.remove();
groups[activeGroup].slider = null;
groups[activeGroup].sliderElements = [];
groups[activeGroup].images = [];
GROUPS[activeGroup].slider.remove();
GROUPS[activeGroup].slider = null;
GROUPS[activeGroup].sliderElements = [];
GROUPS[activeGroup].images = [];
}, {

@@ -540,3 +540,3 @@ once: true

detail: {
source: groups[activeGroup].gallery[currentIndex]
source: GROUPS[activeGroup].gallery[currentIndex]
}

@@ -554,8 +554,8 @@ });

const preload = function preload(index) {
if (groups[activeGroup].gallery[index] === undefined) {
if (GROUPS[activeGroup].gallery[index] === undefined) {
return;
}
createSlide(groups[activeGroup].gallery[index], index);
createImage(groups[activeGroup].gallery[index], index, function () {
createSlide(index);
createImage(GROUPS[activeGroup].gallery[index], index, function () {
loadImage(index);

@@ -572,4 +572,4 @@ });

const loadSlide = function loadSlide(index) {
groups[activeGroup].sliderElements[index].classList.add('parvus__slide--is-active');
groups[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'false');
GROUPS[activeGroup].sliderElements[index].classList.add('parvus__slide--is-active');
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'false');
};

@@ -579,5 +579,5 @@ /**

*
* @param {HTMLElement} el
* @param {Number} index
* @param {HTMLElement} el
* @param {HTMLElement} container
* @param {Function} callback
*/

@@ -587,4 +587,4 @@

const createImage = function createImage(el, index, callback) {
if (groups[activeGroup].images[index] !== undefined) ; else {
const container = groups[activeGroup].sliderElements[index].querySelector('div');
if (GROUPS[activeGroup].images[index] !== undefined) ; else {
const container = GROUPS[activeGroup].sliderElements[index].querySelector('div');
const IMAGE = document.createElement('img');

@@ -609,3 +609,3 @@ const IMAGE_CONTAINER = document.createElement('div');

IMAGE.setAttribute('height', IMAGE.naturalHeight);
setImageDimension(groups[activeGroup].sliderElements[index], IMAGE);
setImageDimension(GROUPS[activeGroup].sliderElements[index], IMAGE);

@@ -637,3 +637,3 @@ if (callback && typeof callback === 'function') {

IMAGE_CONTAINER.appendChild(IMAGE);
groups[activeGroup].images[index] = IMAGE;
GROUPS[activeGroup].images[index] = IMAGE;
container.appendChild(IMAGE_CONTAINER); // Add caption if available

@@ -661,2 +661,4 @@

if (captionData !== null) {
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-labelledby', `parvus__caption-${index}`);
CAPTION_CONTAINER.id = `parvus__caption-${index}`;
CAPTION_CONTAINER.innerHTML = `<p>${captionData}</p>`;

@@ -676,5 +678,5 @@ container.appendChild(CAPTION_CONTAINER);

const loadImage = function loadImage(index) {
const IMAGE = groups[activeGroup].images[index];
const IMAGE = GROUPS[activeGroup].images[index];
const IMAGE_SIZE = IMAGE.getBoundingClientRect();
const THUMBNAIL = groups[activeGroup].gallery[index];
const THUMBNAIL = GROUPS[activeGroup].gallery[index];
const THUMBNAIL_SIZE = THUMBNAIL.getBoundingClientRect();

@@ -704,7 +706,7 @@

*
* @param {Number} newIndex
* @param {Number} index
*/
const select = function select(newIndex) {
const select = function select(index) {
const OLD_INDEX = currentIndex;

@@ -715,12 +717,12 @@

} else {
if (!newIndex && newIndex !== 0) {
if (!index && index !== 0) {
throw new Error('Ups, no slide specified.');
}
if (newIndex === currentIndex) {
throw new Error(`Ups, slide ${newIndex} is already selected.`);
if (index === currentIndex) {
throw new Error(`Ups, slide ${index} is already selected.`);
}
if (newIndex === -1 || newIndex >= groups[activeGroup].gallery.length) {
throw new Error(`Ups, I can't find slide ${newIndex}.`);
if (index === -1 || index >= GROUPS[activeGroup].gallery.length) {
throw new Error(`Ups, I can't find slide ${index}.`);
}

@@ -730,6 +732,6 @@ }

leaveSlide(OLD_INDEX);
loadSlide(newIndex);
loadImage(newIndex);
loadSlide(index);
loadImage(index);
if (newIndex < OLD_INDEX) {
if (index < OLD_INDEX) {
currentIndex--;

@@ -739,6 +741,6 @@ updateOffset();

updateFocus('left');
preload(newIndex - 1);
preload(index - 1);
}
if (newIndex > OLD_INDEX) {
if (index > OLD_INDEX) {
currentIndex++;

@@ -748,3 +750,3 @@ updateOffset();

updateFocus('right');
preload(newIndex + 1);
preload(index + 1);
}

@@ -756,3 +758,3 @@

detail: {
source: groups[activeGroup].gallery[currentIndex]
source: GROUPS[activeGroup].gallery[currentIndex]
}

@@ -780,3 +782,3 @@ });

const next = function next() {
if (currentIndex < groups[activeGroup].gallery.length - 1) {
if (currentIndex < GROUPS[activeGroup].gallery.length - 1) {
select(currentIndex + 1);

@@ -794,4 +796,4 @@ }

const leaveSlide = function leaveSlide(index) {
groups[activeGroup].sliderElements[index].classList.remove('parvus__slide--is-active');
groups[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'true');
GROUPS[activeGroup].sliderElements[index].classList.remove('parvus__slide--is-active');
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'true');
};

@@ -807,3 +809,3 @@ /**

offset = currentIndex * lightbox.offsetWidth * -1;
groups[activeGroup].slider.style.transform = `translate3d(${offset}px, 0, 0)`;
GROUPS[activeGroup].slider.style.transform = `translate3d(${offset}px, 0, 0)`;
offsetTmp = offset;

@@ -819,3 +821,3 @@ };

const updateFocus = function updateFocus(dir) {
if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
closeButton.focus();

@@ -826,3 +828,3 @@ } else {

nextButton.focus(); // If the last slide is displayed
} else if (currentIndex === groups[activeGroup].gallery.length - 1) {
} else if (currentIndex === GROUPS[activeGroup].gallery.length - 1) {
previousButton.focus();

@@ -845,3 +847,3 @@ } else {

const updateCounter = function updateCounter() {
counter.textContent = `${currentIndex + 1}/${groups[activeGroup].gallery.length}`;
counter.textContent = `${currentIndex + 1}/${GROUPS[activeGroup].gallery.length}`;
};

@@ -876,3 +878,3 @@ /**

previous();
} else if (isDraggingX && MOVEMENT_X < 0 && MOVEMENT_X_DISTANCE >= config.threshold && currentIndex !== groups[activeGroup].gallery.length - 1) {
} else if (isDraggingX && MOVEMENT_X < 0 && MOVEMENT_X_DISTANCE >= config.threshold && currentIndex !== GROUPS[activeGroup].gallery.length - 1) {
next();

@@ -898,8 +900,8 @@ } else if (isDraggingY && MOVEMENT_Y_DISTANCE > 0) {

const updateConfig = function updateConfig() {
if (config.swipeClose && !groups[activeGroup].slider.classList.contains('parvus__slider--is-draggable') || groups[activeGroup].gallery.length > 1 && !groups[activeGroup].slider.classList.contains('parvus__slider--is-draggable')) {
groups[activeGroup].slider.classList.add('parvus__slider--is-draggable');
if (config.swipeClose && !GROUPS[activeGroup].slider.classList.contains('parvus__slider--is-draggable') || GROUPS[activeGroup].gallery.length > 1 && !GROUPS[activeGroup].slider.classList.contains('parvus__slider--is-draggable')) {
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-draggable');
} // Hide buttons if necessary
if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
previousButton.setAttribute('aria-hidden', 'true');

@@ -916,3 +918,3 @@ previousButton.disabled = true;

nextButton.disabled = false; // If the last slide is displayed
} else if (currentIndex === groups[activeGroup].gallery.length - 1) {
} else if (currentIndex === GROUPS[activeGroup].gallery.length - 1) {
previousButton.setAttribute('aria-hidden', 'false');

@@ -931,3 +933,3 @@ previousButton.disabled = false;

if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
counter.setAttribute('aria-hidden', 'true');

@@ -948,3 +950,5 @@ } else {

BROWSER_WINDOW.requestAnimationFrame(() => {
setImageDimension(groups[activeGroup].sliderElements[currentIndex], groups[activeGroup].images[currentIndex]);
GROUPS[activeGroup].sliderElements.forEach((slide, index) => {
setImageDimension(slide, GROUPS[activeGroup].images[index]);
});
updateOffset();

@@ -966,4 +970,4 @@ resizeTicking = false;

const captionRec = slideEl.querySelector('.parvus__caption') !== null ? slideEl.querySelector('.parvus__caption').getBoundingClientRect().height : 0;
const srcHeight = imageEl.naturalHeight;
const srcWidth = imageEl.naturalWidth;
const srcHeight = imageEl.getAttribute('height');
const srcWidth = imageEl.getAttribute('width');
let maxHeight = slideEl.getBoundingClientRect().height;

@@ -973,11 +977,13 @@ let maxWidth = slideEl.getBoundingClientRect().width;

maxWidth -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
const ratio = Math.min(maxWidth / srcWidth || 0, maxHeight / srcHeight);
const newWidth = srcWidth * ratio || 0;
const newHeight = srcHeight * ratio || 0;
if (imageEl.naturalHeight < maxHeight && imageEl.naturalWidth < maxWidth) {
maxHeight = imageEl.naturalHeight;
maxWidth = imageEl.naturalWidth;
if (srcHeight > newHeight && srcHeight < maxHeight && srcWidth > newWidth && srcWidth < maxWidth || srcHeight < newHeight && srcHeight < maxHeight && srcWidth < newWidth && srcWidth < maxWidth) {
imageEl.style.width = '';
imageEl.style.height = '';
} else {
imageEl.style.width = `${newWidth}px`;
imageEl.style.height = `${newHeight}px`;
}
const ratio = Math.min(maxWidth / srcWidth || 0, maxHeight / srcHeight);
imageEl.style.width = `${srcWidth * ratio || 0}px`;
imageEl.style.height = `${srcHeight * ratio || 0}px`;
};

@@ -1019,3 +1025,3 @@ /**

const getFocusableChildren = function getFocusableChildren() {
return Array.prototype.slice.call(lightbox.querySelectorAll(`${FOCUSABLE_ELEMENTS.join(', ')}`)).filter(function (child) {
return Array.prototype.slice.call(lightbox.querySelectorAll(`${FOCUSABLE_ELEMENTS.join(', ')}`)).filter(child => {
return !!(child.offsetWidth || child.offsetHeight || child.getClientRects().length);

@@ -1093,4 +1099,4 @@ });

drag.startY = event.pageY;
groups[activeGroup].slider.classList.add('parvus__slider--is-dragging');
groups[activeGroup].slider.style.willChange = 'transform';
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-dragging');
GROUPS[activeGroup].slider.style.willChange = 'transform';
};

@@ -1121,4 +1127,4 @@ /**

pointerDown = false;
groups[activeGroup].slider.classList.remove('parvus__slider--is-dragging');
groups[activeGroup].slider.style.willChange = 'auto';
GROUPS[activeGroup].slider.classList.remove('parvus__slider--is-dragging');
GROUPS[activeGroup].slider.style.willChange = 'auto';

@@ -1144,4 +1150,4 @@ if (drag.endX || drag.endY) {

drag.startY = event.touches[0].pageY;
groups[activeGroup].slider.classList.add('parvus__slider--is-dragging');
groups[activeGroup].slider.style.willChange = 'transform';
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-dragging');
GROUPS[activeGroup].slider.style.willChange = 'transform';
};

@@ -1173,4 +1179,4 @@ /**

pointerDown = false;
groups[activeGroup].slider.classList.remove('parvus__slider--is-dragging');
groups[activeGroup].slider.style.willChange = 'auto';
GROUPS[activeGroup].slider.classList.remove('parvus__slider--is-dragging');
GROUPS[activeGroup].slider.style.willChange = 'auto';

@@ -1194,5 +1200,5 @@ if (drag.endX || drag.endY) {

if (Math.abs(MOVEMENT_X) > 0 && !isDraggingY && groups[activeGroup].gallery.length > 1) {
if (Math.abs(MOVEMENT_X) > 0 && !isDraggingY && GROUPS[activeGroup].gallery.length > 1) {
// Horizontal swipe
groups[activeGroup].slider.style.transform = `translate3d(${offsetTmp - Math.round(MOVEMENT_X)}px, 0, 0)`;
GROUPS[activeGroup].slider.style.transform = `translate3d(${offsetTmp - Math.round(MOVEMENT_X)}px, 0, 0)`;
isDraggingX = true;

@@ -1209,3 +1215,3 @@ isDraggingY = false;

lightboxOverlay.style.opacity = lightboxOverlayOpacity;
groups[activeGroup].slider.style.transform = `translate3d(${offsetTmp}px, ${Math.round(MOVEMENT_Y)}px, 0)`;
GROUPS[activeGroup].slider.style.transform = `translate3d(${offsetTmp}px, ${Math.round(MOVEMENT_Y)}px, 0)`;
isDraggingX = false;

@@ -1212,0 +1218,0 @@ isDraggingY = true;

@@ -5,3 +5,3 @@ /**

* @author Benjamin de Oostfrees
* @version 2.0.3
* @version 2.0.4
* @url https://github.com/deoostfrees/parvus

@@ -12,2 +12,2 @@ *

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Parvus=t()}(this,(function(){"use strict";var e={lightboxLabel:"This is a dialog window which overlays the main content of the page. The modal shows the enlarged image. Pressing the Escape key will close the modal and bring you back to where you were on the page.",lightboxLoadingIndicatorLabel:"Image loading",previousButtonLabel:"Previous image",nextButtonLabel:"Next image",closeButtonLabel:"Close dialog window"};return function t(n){const i=window,s=["button:not([disabled]):not([inert])",'[tabindex]:not([tabindex^="-"]):not([inert])'],a={gallery:[],slider:null,sliderElements:[],images:[]};let r={},l=null,o=null,d=0,u={},c=null,p=null,g=1,h=null,m=null,f=null,v=null,b=null,y=null,w=null,E=0,A=0,L=0,_=0,C={},x=!1,$=!1,S=!1,T=null,B=null,M=null,q=!1,F=null,I=!0;const N=window.matchMedia("(prefers-reduced-motion)"),X=function(){N.matches?(I=!0,F=u.reducedTransitionDuration):(I=!1,F=u.transitionDuration)};N.addEventListener("change",X);const Y=function(t){u=function(t){return{selector:".lightbox",gallerySelector:null,captions:!0,captionsSelector:"self",captionsAttribute:"data-caption",docClose:!0,scrollClose:!1,swipeClose:!0,threshold:50,backFocus:!0,transitionDuration:300,reducedTransitionDuration:.1,transitionTimingFunction:"cubic-bezier(0.4, 0, 0.22, 1)",lightboxIndicatorIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"/></svg>',previousButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>',nextButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>',closeButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18M6 6l12 12"/></svg>',l10n:e,fileTypes:/\.(png|jpe?g|webp|avif|svg)(\?.*)?$/i,...t}}(t);if(document.querySelectorAll(u.selector).length)if(X(),c||O(),null!==u.gallerySelector){document.querySelectorAll(u.gallerySelector).forEach(((e,t)=>{const n=t;e.querySelectorAll(u.selector).forEach((e=>{e.setAttribute("data-group",`parvus-gallery-${n}`),H(e)}))}));document.querySelectorAll(`${u.selector}:not(.parvus-trigger)`).forEach((e=>{H(e)}))}else{document.querySelectorAll(u.selector).forEach((e=>{H(e)}))}},k=function(e){const t=Math.floor(1e4*Math.random());return e.hasAttribute("data-group")&&""!==e.getAttribute("data-group")||e.setAttribute("data-group",`default-${t}`),e.getAttribute("data-group")},H=function(e){if(!("A"===e.tagName&&e.hasAttribute("href")&&e.href.match(u.fileTypes)||"BUTTON"===e.tagName&&e.hasAttribute("data-target")&&e.getAttribute("data-target").match(u.fileTypes)))throw new Error(e,`Use a link with the 'href' attribute or a button with the 'data-target' attribute. Both attributes must have a path to the image file. Supported image file types: ${u.fileTypes}.`);var t;if(l=k(e),Object.prototype.hasOwnProperty.call(r,l)||(r[l]=(t=a,JSON.parse(JSON.stringify(t)))),r[l].gallery.includes(e))throw new Error("Ups, element already added.");if(r[l].gallery.push(e),null!==e.querySelector("img")){const t=document.createElement("div");e.classList.add("parvus-zoom"),t.className="parvus-zoom__indicator",t.innerHTML=u.lightboxIndicatorIcon,e.appendChild(t)}e.classList.add("parvus-trigger"),e.addEventListener("click",le),Ae()&&l===o&&(z(e,r[l].gallery.indexOf(e)),j(e,r[l].gallery.indexOf(e),(function(){J(r[l].gallery.indexOf(e))})),se(),ee(),te())},D=function(e){if(Ae()||!c||!e||!e.hasAttribute("data-group"))return;const t=k(e);if(!r[t].gallery.includes(e))throw new Error("Ups, I can't find the element.");if(r[t].gallery.splice(r[t].gallery.indexOf(e),1),e.classList.contains("parvus-zoom")){const t=e.querySelector(".parvus-zoom__indicator");e.classList.remove("parvus-zoom"),e.removeChild(t)}e.removeEventListener("click",le),e.classList.remove("parvus-trigger")},O=function(){c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-hidden","true"),c.setAttribute("tabindex","-1"),c.setAttribute("aria-label",u.l10n.lightboxLabel),c.classList.add("parvus"),p=document.createElement("div"),p.classList.add("parvus__overlay"),p.style.opacity=0,c.appendChild(p),h=document.createElement("div"),h.className="parvus__toolbar",m=document.createElement("div"),f=document.createElement("div"),y=document.createElement("button"),y.className="parvus__btn parvus__btn--close",y.setAttribute("type","button"),y.setAttribute("aria-label",u.l10n.closeButtonLabel),y.innerHTML=u.closeButtonIcon,f.appendChild(y),v=document.createElement("button"),v.className="parvus__btn parvus__btn--previous",v.setAttribute("type","button"),v.setAttribute("aria-label",u.l10n.previousButtonLabel),v.innerHTML=u.previousButtonIcon,c.appendChild(v),b=document.createElement("button"),b.className="parvus__btn parvus__btn--next",b.setAttribute("type","button"),b.setAttribute("aria-label",u.l10n.nextButtonLabel),b.innerHTML=u.nextButtonIcon,c.appendChild(b),w=document.createElement("div"),w.className="parvus__counter",m.appendChild(w),h.appendChild(m),h.appendChild(f),c.appendChild(h),document.body.appendChild(c)},z=function(e,t){if(void 0!==r[o].sliderElements[t]);else{const e=document.createElement("div"),n=document.createElement("div");e.className="parvus__slide",e.style.position="absolute",e.style.left=100*t+"%",e.setAttribute("aria-hidden","true"),e.appendChild(n),r[o].sliderElements[t]=e,t===d&&r[o].slider.appendChild(e),t>d?r[o].sliderElements[d].after(e):r[o].sliderElements[d].before(e)}},P=function(e){if(!c||!e||!e.classList.contains("parvus-trigger")||Ae())return;if(o=k(e),!r[o].gallery.includes(e))throw new Error("Ups, I can't find the element.");d=r[o].gallery.indexOf(e),T=document.activeElement;const t=window.location.href;history.pushState({parvus:"close"},"Image",t),we();document.querySelectorAll('body > *:not([aria-hidden="true"])').forEach((e=>{e.setAttribute("aria-hidden","true"),e.classList.add("parvus-hidden")})),c.classList.add("parvus--is-opening"),c.setAttribute("aria-hidden","false"),r[o].slider=document.createElement("div"),r[o].slider.className="parvus__slider",r[o].slider.setAttribute("aria-hidden","true"),c.appendChild(r[o].slider),z(e,d),r[o].slider.setAttribute("aria-hidden","false"),Z(),se(),te(),ue(),W(d),j(e,d,(function(){J(d),requestAnimationFrame((()=>{c.classList.remove("parvus--is-opening"),p.style.opacity=1,p.style.transition=`opacity ${F}ms ${u.transitionTimingFunction}`,p.style.willChange="opacity"})),p.addEventListener("transitionend",(()=>{U(d+1),U(d-1)})),r[o].slider.classList.add("parvus__slider--animate")}));const n=new CustomEvent("open",{detail:{source:e}});c.dispatchEvent(n)},R=function(){if(!Ae())throw new Error("Ups, I'm already closed.");const e=r[o].images[d],t=e.getBoundingClientRect(),n=(u.backFocus?r[o].gallery[d]:T).getBoundingClientRect();Ee(),ne(),null!==history.state&&"close"===history.state.parvus&&history.back();document.querySelectorAll(".parvus-hidden").forEach((e=>{e.removeAttribute("aria-hidden"),e.classList.remove("parvus-hidden")})),c.classList.add("parvus--is-closing"),requestAnimationFrame((()=>{E=n.width/t.width,A=n.height/t.height,L=n.left-t.left,_=n.top-t.top,e.style.transform=`translate(${L}px, ${_}px) scale(${E}, ${A})`,e.style.opacity=0,e.style.transition=`transform ${F}ms ${u.transitionTimingFunction}, opacity ${F}ms ${u.transitionTimingFunction} ${F/2}ms`,p.style.opacity=0,p.style.transition=`opacity ${F}ms ${u.transitionTimingFunction}`,p.style.willChange="auto"})),p.addEventListener("transitionend",(()=>{Q(d),T=u.backFocus?r[o].gallery[d]:T,T.focus({preventScroll:!0}),c.setAttribute("aria-hidden","true"),c.classList.remove("parvus--is-closing"),c.classList.remove("parvus--is-vertical-closing"),e.style.transform="",r[o].slider.remove(),r[o].slider=null,r[o].sliderElements=[],r[o].images=[]}),{once:!0});const i=new CustomEvent("close",{detail:{source:r[o].gallery[d]}});c.dispatchEvent(i)},U=function(e){void 0!==r[o].gallery[e]&&(z(r[o].gallery[e],e),j(r[o].gallery[e],e,(function(){J(e)})))},W=function(e){r[o].sliderElements[e].classList.add("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","false")},j=function(e,t,n){if(void 0!==r[o].images[t]);else{const i=r[o].sliderElements[t].querySelector("div"),s=document.createElement("img"),a=document.createElement("div"),l=document.createElement("div"),d=e.querySelector("img"),c=document.createElement("div");if(a.className="parvus__content",l.className="parvus__caption",c.className="parvus__loader",c.setAttribute("role","progressbar"),c.setAttribute("aria-label",u.l10n.lightboxLoadingIndicatorLabel),i.appendChild(c),s.onload=()=>{i.removeChild(c),s.setAttribute("width",s.naturalWidth),s.setAttribute("height",s.naturalHeight),re(r[o].sliderElements[t],s),n&&"function"==typeof n&&n()},"A"===e.tagName?(s.setAttribute("src",e.href),s.alt=d?d.alt||"":e.getAttribute("data-alt")||""):(s.alt=e.getAttribute("data-alt")||"",s.setAttribute("src",e.getAttribute("data-target"))),e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&s.setAttribute("srcset",e.getAttribute("data-srcset")),s.style.opacity=0,a.appendChild(s),r[o].images[t]=s,i.appendChild(a),u.captions){let t=null;if("self"===u.captionsSelector)e.hasAttribute(u.captionsAttribute)&&""!==e.getAttribute(u.captionsAttribute)&&(t=e.getAttribute(u.captionsAttribute));else if(null!==e.querySelector(u.captionsSelector)){const n=e.querySelector(u.captionsSelector);t=n.hasAttribute(u.captionsAttribute)&&""!==n.getAttribute(u.captionsAttribute)?n.getAttribute(u.captionsAttribute):n.innerHTML}null!==t&&(l.innerHTML=`<p>${t}</p>`,i.appendChild(l))}}},J=function(e){const t=r[o].images[e],n=t.getBoundingClientRect(),i=r[o].gallery[e].getBoundingClientRect();c.classList.contains("parvus--is-opening")?(E=i.width/n.width,A=i.height/n.height,L=i.left-n.left,_=i.top-n.top,requestAnimationFrame((()=>{t.style.transform=`translate(${L}px, ${_}px) scale(${E}, ${A})`,t.style.transition="transform 0s, opacity 0s",requestAnimationFrame((()=>{t.style.transform="",t.style.opacity=1,t.style.transition=`transform ${F}ms ${u.transitionTimingFunction}, opacity ${F/2}ms ${u.transitionTimingFunction}`}))}))):t.style.opacity=1},K=function(e){const t=d;if(!Ae())throw new Error("Ups, I'm closed.");if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===d)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=r[o].gallery.length)throw new Error(`Ups, I can't find slide ${e}.`);Q(t),W(e),J(e),e<t&&(d--,Z(),se(),ee("left"),U(e-1)),e>t&&(d++,Z(),se(),ee("right"),U(e+1)),te();const n=new CustomEvent("select",{detail:{source:r[o].gallery[d]}});c.dispatchEvent(n)},V=function(){d>0&&K(d-1)},G=function(){d<r[o].gallery.length-1&&K(d+1)},Q=function(e){r[o].sliderElements[e].classList.remove("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","true")},Z=function(){o=null!==o?o:l,B=d*c.offsetWidth*-1,r[o].slider.style.transform=`translate3d(${B}px, 0, 0)`,M=B},ee=function(e){1===r[o].gallery.length?y.focus():0===d?b.focus():d===r[o].gallery.length-1||"left"===e?v.focus():b.focus()},te=function(){w.textContent=`${d+1}/${r[o].gallery.length}`},ne=function(){C={startX:0,endX:0,startY:0,endY:0}},ie=function(){const e=C.endX-C.startX,t=C.endY-C.startY,n=Math.abs(e),i=Math.abs(t);x&&e>0&&n>=u.threshold&&d>0?V():x&&e<0&&n>=u.threshold&&d!==r[o].gallery.length-1?G():$&&i>0?i>=u.threshold&&u.swipeClose?R():(p.style.opacity=1,c.classList.remove("parvus--is-vertical-closing"),Z()):Z()},se=function(){(u.swipeClose&&!r[o].slider.classList.contains("parvus__slider--is-draggable")||r[o].gallery.length>1&&!r[o].slider.classList.contains("parvus__slider--is-draggable"))&&r[o].slider.classList.add("parvus__slider--is-draggable"),1===r[o].gallery.length?(v.setAttribute("aria-hidden","true"),v.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0):0===d?(v.setAttribute("aria-hidden","true"),v.disabled=!0,b.setAttribute("aria-hidden","false"),b.disabled=!1):d===r[o].gallery.length-1?(v.setAttribute("aria-hidden","false"),v.disabled=!1,b.setAttribute("aria-hidden","true"),b.disabled=!0):(v.setAttribute("aria-hidden","false"),v.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1),1===r[o].gallery.length?w.setAttribute("aria-hidden","true"):w.setAttribute("aria-hidden","false")},ae=function(){q||(q=!0,i.requestAnimationFrame((()=>{re(r[o].sliderElements[d],r[o].images[d]),Z(),q=!1})))},re=function(e,t){const n=getComputedStyle(e),i=null!==e.querySelector(".parvus__caption")?e.querySelector(".parvus__caption").getBoundingClientRect().height:0,s=t.naturalHeight,a=t.naturalWidth;let r=e.getBoundingClientRect().height,l=e.getBoundingClientRect().width;r-=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)+parseFloat(i),l-=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight),t.naturalHeight<r&&t.naturalWidth<l&&(r=t.naturalHeight,l=t.naturalWidth);const o=Math.min(l/a||0,r/s);t.style.width=`${a*o||0}px`,t.style.height=`${s*o||0}px`},le=function(e){e.preventDefault(),P(this)},oe=function(e){e.target===v?V():e.target===b?G():(e.target===y||!$&&!x&&e.target.classList.contains("parvus__slide")&&u.docClose)&&R(),e.stopPropagation()},de=function(){return Array.prototype.slice.call(c.querySelectorAll(`${s.join(", ")}`)).filter((function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}))},ue=function(){de()[0].focus()},ce=function(e){const t=de(),n=t.indexOf(document.activeElement);"Tab"===e.code?e.shiftKey&&0===n?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||n!==t.length-1||(t[0].focus(),e.preventDefault()):"Escape"===e.code?(e.preventDefault(),R()):"ArrowLeft"===e.code?(e.preventDefault(),V()):"ArrowRight"===e.code&&(e.preventDefault(),G())},pe=function(){R()},ge=function(e){e.preventDefault(),e.stopPropagation(),x=!1,$=!1,S=!0,C.startX=e.pageX,C.startY=e.pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},he=function(e){e.preventDefault(),S&&(C.endX=e.pageX,C.endY=e.pageY,ye())},me=function(e){e.stopPropagation(),S=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(C.endX||C.endY)&&ie(),ne()},fe=function(e){e.stopPropagation(),x=!1,$=!1,S=!0,C.startX=e.touches[0].pageX,C.startY=e.touches[0].pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},ve=function(e){e.stopPropagation(),S&&(e.preventDefault(),C.endX=e.touches[0].pageX,C.endY=e.touches[0].pageY,ye())},be=function(e){e.stopPropagation(),S=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(C.endX||C.endY)&&ie(),ne()},ye=function(){const e=C.startX-C.endX,t=C.endY-C.startY,n=Math.abs(t);Math.abs(e)>0&&!$&&r[o].gallery.length>1?(r[o].slider.style.transform=`translate3d(${M-Math.round(e)}px, 0, 0)`,x=!0,$=!1):Math.abs(t)>0&&!x&&u.swipeClose&&(n<=96&&!I&&(g=1-n/100),c.classList.add("parvus--is-vertical-closing"),p.style.opacity=g,r[o].slider.style.transform=`translate3d(${M}px, ${Math.round(t)}px, 0)`,x=!1,$=!0)},we=function(){i.addEventListener("keydown",ce),i.addEventListener("resize",ae),u.scrollClose&&i.addEventListener("wheel",pe),i.addEventListener("popstate",R),c.addEventListener("click",oe),Le()&&(c.addEventListener("touchstart",fe),c.addEventListener("touchmove",ve),c.addEventListener("touchend",be)),c.addEventListener("mousedown",ge),c.addEventListener("mouseup",me),c.addEventListener("mousemove",he)},Ee=function(){i.removeEventListener("keydown",ce),i.removeEventListener("resize",ae),u.scrollClose&&i.removeEventListener("wheel",pe),i.removeEventListener("popstate",R),c.removeEventListener("click",oe),Le()&&(c.removeEventListener("touchstart",fe),c.removeEventListener("touchmove",ve),c.removeEventListener("touchend",be)),c.removeEventListener("mousedown",ge),c.removeEventListener("mouseup",me),c.removeEventListener("mousemove",he)},Ae=function(){return"false"===c.getAttribute("aria-hidden")},Le=function(){return"ontouchstart"in window};return Y(n),t.init=Y,t.open=P,t.close=R,t.select=K,t.previous=V,t.next=G,t.currentIndex=function(){return d},t.add=H,t.remove=D,t.destroy=function(){if(!c)return;Ae()&&R(),c.remove();document.querySelectorAll(".parvus-trigger").forEach((e=>{D(e)}));const e=new CustomEvent("destroy");c.dispatchEvent(e)},t.isOpen=Ae,t.on=function(e,t){c&&c.addEventListener(e,t)},t.off=function(e,t){c&&c.removeEventListener(e,t)},t}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Parvus=t()}(this,(function(){"use strict";var e={lightboxLabel:"This is a dialog window which overlays the main content of the page. The modal shows the enlarged image. Pressing the Escape key will close the modal and bring you back to where you were on the page.",lightboxLoadingIndicatorLabel:"Image loading",previousButtonLabel:"Previous image",nextButtonLabel:"Next image",closeButtonLabel:"Close dialog window"};return function t(n){const i=window,s=["button:not([disabled]):not([inert])",'[tabindex]:not([tabindex^="-"]):not([inert])'],a={gallery:[],slider:null,sliderElements:[],images:[]},r={};let l=null,o=null,d=0,u={},c=null,p=null,g=1,h=null,m=null,v=null,f=null,b=null,y=null,w=null,E=0,A=0,L=0,_=0,C={},x=!1,$=!1,S=!1,T=null,B=null,M=null,q=!1,F=null,I=!0;const N=window.matchMedia("(prefers-reduced-motion)"),X=function(){N.matches?(I=!0,F=u.reducedTransitionDuration):(I=!1,F=u.transitionDuration)};N.addEventListener("change",X);const Y=function(t){u=function(t){return{selector:".lightbox",gallerySelector:null,captions:!0,captionsSelector:"self",captionsAttribute:"data-caption",docClose:!0,scrollClose:!1,swipeClose:!0,threshold:50,backFocus:!0,transitionDuration:300,reducedTransitionDuration:.1,transitionTimingFunction:"cubic-bezier(0.4, 0, 0.22, 1)",lightboxIndicatorIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"/></svg>',previousButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>',nextButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>',closeButtonIcon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18M6 6l12 12"/></svg>',l10n:e,fileTypes:/\.(png|jpe?g|webp|avif|svg)(\?.*)?$/i,...t}}(t);if(document.querySelectorAll(u.selector).length)if(X(),c||H(),null!==u.gallerySelector){document.querySelectorAll(u.gallerySelector).forEach(((e,t)=>{const n=t;e.querySelectorAll(u.selector).forEach((e=>{e.setAttribute("data-group",`parvus-gallery-${n}`),D(e)}))}));document.querySelectorAll(`${u.selector}:not(.parvus-trigger)`).forEach((e=>{D(e)}))}else{document.querySelectorAll(u.selector).forEach((e=>{D(e)}))}},k=function(e){const t=Math.floor(1e4*Math.random());return e.hasAttribute("data-group")&&""!==e.getAttribute("data-group")||e.setAttribute("data-group",`default-${t}`),e.getAttribute("data-group")},D=function(e){if(!("A"===e.tagName&&e.hasAttribute("href")&&e.href.match(u.fileTypes)||"BUTTON"===e.tagName&&e.hasAttribute("data-target")&&e.getAttribute("data-target").match(u.fileTypes)))throw new Error(e,`Use a link with the 'href' attribute or a button with the 'data-target' attribute. Both attributes must have a path to the image file. Supported image file types: ${u.fileTypes}.`);var t;if(l=k(e),Object.prototype.hasOwnProperty.call(r,l)||(r[l]=(t=a,JSON.parse(JSON.stringify(t)))),r[l].gallery.includes(e))throw new Error("Ups, element already added.");if(r[l].gallery.push(e),null!==e.querySelector("img")){const t=document.createElement("div");e.classList.add("parvus-zoom"),t.className="parvus-zoom__indicator",t.innerHTML=u.lightboxIndicatorIcon,e.appendChild(t)}e.classList.add("parvus-trigger"),e.addEventListener("click",le),Ae()&&l===o&&(z(r[l].gallery.indexOf(e)),W(e,r[l].gallery.indexOf(e),(function(){J(r[l].gallery.indexOf(e))})),se(),ee(),te())},O=function(e){if(Ae()||!c||!e||!e.hasAttribute("data-group"))return;const t=k(e);if(!r[t].gallery.includes(e))throw new Error("Ups, I can't find the element.");if(r[t].gallery.splice(r[t].gallery.indexOf(e),1),e.classList.contains("parvus-zoom")){const t=e.querySelector(".parvus-zoom__indicator");e.classList.remove("parvus-zoom"),e.removeChild(t)}e.removeEventListener("click",le),e.classList.remove("parvus-trigger")},H=function(){c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-hidden","true"),c.setAttribute("tabindex","-1"),c.setAttribute("aria-label",u.l10n.lightboxLabel),c.classList.add("parvus"),p=document.createElement("div"),p.classList.add("parvus__overlay"),p.style.opacity=0,c.appendChild(p),h=document.createElement("div"),h.className="parvus__toolbar",m=document.createElement("div"),v=document.createElement("div"),y=document.createElement("button"),y.className="parvus__btn parvus__btn--close",y.setAttribute("type","button"),y.setAttribute("aria-label",u.l10n.closeButtonLabel),y.innerHTML=u.closeButtonIcon,v.appendChild(y),f=document.createElement("button"),f.className="parvus__btn parvus__btn--previous",f.setAttribute("type","button"),f.setAttribute("aria-label",u.l10n.previousButtonLabel),f.innerHTML=u.previousButtonIcon,c.appendChild(f),b=document.createElement("button"),b.className="parvus__btn parvus__btn--next",b.setAttribute("type","button"),b.setAttribute("aria-label",u.l10n.nextButtonLabel),b.innerHTML=u.nextButtonIcon,c.appendChild(b),w=document.createElement("div"),w.className="parvus__counter",m.appendChild(w),h.appendChild(m),h.appendChild(v),c.appendChild(h),document.body.appendChild(c)},z=function(e){if(void 0!==r[o].sliderElements[e]);else{const t=document.createElement("div"),n=document.createElement("div");t.className="parvus__slide",t.style.position="absolute",t.style.left=100*e+"%",t.setAttribute("aria-hidden","true"),t.appendChild(n),r[o].sliderElements[e]=t,e===d&&r[o].slider.appendChild(t),e>d?r[o].sliderElements[d].after(t):r[o].sliderElements[d].before(t)}},P=function(e){if(!c||!e||!e.classList.contains("parvus-trigger")||Ae())return;if(o=k(e),!r[o].gallery.includes(e))throw new Error("Ups, I can't find the element.");d=r[o].gallery.indexOf(e),T=document.activeElement;const t=window.location.href;history.pushState({parvus:"close"},"Image",t),we();document.querySelectorAll('body > *:not([aria-hidden="true"])').forEach((e=>{e.setAttribute("aria-hidden","true"),e.classList.add("parvus-hidden")})),c.classList.add("parvus--is-opening"),c.setAttribute("aria-hidden","false"),r[o].slider=document.createElement("div"),r[o].slider.className="parvus__slider",r[o].slider.setAttribute("aria-hidden","true"),c.appendChild(r[o].slider),z(d),r[o].slider.setAttribute("aria-hidden","false"),Z(),se(),te(),ue(),j(d),W(e,d,(function(){J(d),requestAnimationFrame((()=>{c.classList.remove("parvus--is-opening"),p.style.opacity=1,p.style.transition=`opacity ${F}ms ${u.transitionTimingFunction}`,p.style.willChange="opacity"})),p.addEventListener("transitionend",(()=>{U(d+1),U(d-1)})),r[o].slider.classList.add("parvus__slider--animate")}));const n=new CustomEvent("open",{detail:{source:e}});c.dispatchEvent(n)},R=function(){if(!Ae())throw new Error("Ups, I'm already closed.");const e=r[o].images[d],t=e.getBoundingClientRect(),n=(u.backFocus?r[o].gallery[d]:T).getBoundingClientRect();Ee(),ne(),null!==history.state&&"close"===history.state.parvus&&history.back();document.querySelectorAll(".parvus-hidden").forEach((e=>{e.removeAttribute("aria-hidden"),e.classList.remove("parvus-hidden")})),c.classList.add("parvus--is-closing"),requestAnimationFrame((()=>{E=n.width/t.width,A=n.height/t.height,L=n.left-t.left,_=n.top-t.top,e.style.transform=`translate(${L}px, ${_}px) scale(${E}, ${A})`,e.style.opacity=0,e.style.transition=`transform ${F}ms ${u.transitionTimingFunction}, opacity ${F}ms ${u.transitionTimingFunction} ${F/2}ms`,p.style.opacity=0,p.style.transition=`opacity ${F}ms ${u.transitionTimingFunction}`,p.style.willChange="auto"})),p.addEventListener("transitionend",(()=>{Q(d),T=u.backFocus?r[o].gallery[d]:T,T.focus({preventScroll:!0}),c.setAttribute("aria-hidden","true"),c.classList.remove("parvus--is-closing"),c.classList.remove("parvus--is-vertical-closing"),e.style.transform="",r[o].slider.remove(),r[o].slider=null,r[o].sliderElements=[],r[o].images=[]}),{once:!0});const i=new CustomEvent("close",{detail:{source:r[o].gallery[d]}});c.dispatchEvent(i)},U=function(e){void 0!==r[o].gallery[e]&&(z(e),W(r[o].gallery[e],e,(function(){J(e)})))},j=function(e){r[o].sliderElements[e].classList.add("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","false")},W=function(e,t,n){if(void 0!==r[o].images[t]);else{const i=r[o].sliderElements[t].querySelector("div"),s=document.createElement("img"),a=document.createElement("div"),l=document.createElement("div"),d=e.querySelector("img"),c=document.createElement("div");if(a.className="parvus__content",l.className="parvus__caption",c.className="parvus__loader",c.setAttribute("role","progressbar"),c.setAttribute("aria-label",u.l10n.lightboxLoadingIndicatorLabel),i.appendChild(c),s.onload=()=>{i.removeChild(c),s.setAttribute("width",s.naturalWidth),s.setAttribute("height",s.naturalHeight),re(r[o].sliderElements[t],s),n&&"function"==typeof n&&n()},"A"===e.tagName?(s.setAttribute("src",e.href),s.alt=d?d.alt||"":e.getAttribute("data-alt")||""):(s.alt=e.getAttribute("data-alt")||"",s.setAttribute("src",e.getAttribute("data-target"))),e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&s.setAttribute("srcset",e.getAttribute("data-srcset")),s.style.opacity=0,a.appendChild(s),r[o].images[t]=s,i.appendChild(a),u.captions){let n=null;if("self"===u.captionsSelector)e.hasAttribute(u.captionsAttribute)&&""!==e.getAttribute(u.captionsAttribute)&&(n=e.getAttribute(u.captionsAttribute));else if(null!==e.querySelector(u.captionsSelector)){const t=e.querySelector(u.captionsSelector);n=t.hasAttribute(u.captionsAttribute)&&""!==t.getAttribute(u.captionsAttribute)?t.getAttribute(u.captionsAttribute):t.innerHTML}null!==n&&(r[o].sliderElements[t].setAttribute("aria-labelledby",`parvus__caption-${t}`),l.id=`parvus__caption-${t}`,l.innerHTML=`<p>${n}</p>`,i.appendChild(l))}}},J=function(e){const t=r[o].images[e],n=t.getBoundingClientRect(),i=r[o].gallery[e].getBoundingClientRect();c.classList.contains("parvus--is-opening")?(E=i.width/n.width,A=i.height/n.height,L=i.left-n.left,_=i.top-n.top,requestAnimationFrame((()=>{t.style.transform=`translate(${L}px, ${_}px) scale(${E}, ${A})`,t.style.transition="transform 0s, opacity 0s",requestAnimationFrame((()=>{t.style.transform="",t.style.opacity=1,t.style.transition=`transform ${F}ms ${u.transitionTimingFunction}, opacity ${F/2}ms ${u.transitionTimingFunction}`}))}))):t.style.opacity=1},K=function(e){const t=d;if(!Ae())throw new Error("Ups, I'm closed.");if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===d)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=r[o].gallery.length)throw new Error(`Ups, I can't find slide ${e}.`);Q(t),j(e),J(e),e<t&&(d--,Z(),se(),ee("left"),U(e-1)),e>t&&(d++,Z(),se(),ee("right"),U(e+1)),te();const n=new CustomEvent("select",{detail:{source:r[o].gallery[d]}});c.dispatchEvent(n)},V=function(){d>0&&K(d-1)},G=function(){d<r[o].gallery.length-1&&K(d+1)},Q=function(e){r[o].sliderElements[e].classList.remove("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","true")},Z=function(){o=null!==o?o:l,B=d*c.offsetWidth*-1,r[o].slider.style.transform=`translate3d(${B}px, 0, 0)`,M=B},ee=function(e){1===r[o].gallery.length?y.focus():0===d?b.focus():d===r[o].gallery.length-1||"left"===e?f.focus():b.focus()},te=function(){w.textContent=`${d+1}/${r[o].gallery.length}`},ne=function(){C={startX:0,endX:0,startY:0,endY:0}},ie=function(){const e=C.endX-C.startX,t=C.endY-C.startY,n=Math.abs(e),i=Math.abs(t);x&&e>0&&n>=u.threshold&&d>0?V():x&&e<0&&n>=u.threshold&&d!==r[o].gallery.length-1?G():$&&i>0?i>=u.threshold&&u.swipeClose?R():(p.style.opacity=1,c.classList.remove("parvus--is-vertical-closing"),Z()):Z()},se=function(){(u.swipeClose&&!r[o].slider.classList.contains("parvus__slider--is-draggable")||r[o].gallery.length>1&&!r[o].slider.classList.contains("parvus__slider--is-draggable"))&&r[o].slider.classList.add("parvus__slider--is-draggable"),1===r[o].gallery.length?(f.setAttribute("aria-hidden","true"),f.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0):0===d?(f.setAttribute("aria-hidden","true"),f.disabled=!0,b.setAttribute("aria-hidden","false"),b.disabled=!1):d===r[o].gallery.length-1?(f.setAttribute("aria-hidden","false"),f.disabled=!1,b.setAttribute("aria-hidden","true"),b.disabled=!0):(f.setAttribute("aria-hidden","false"),f.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1),1===r[o].gallery.length?w.setAttribute("aria-hidden","true"):w.setAttribute("aria-hidden","false")},ae=function(){q||(q=!0,i.requestAnimationFrame((()=>{r[o].sliderElements.forEach(((e,t)=>{re(e,r[o].images[t])})),Z(),q=!1})))},re=function(e,t){const n=getComputedStyle(e),i=null!==e.querySelector(".parvus__caption")?e.querySelector(".parvus__caption").getBoundingClientRect().height:0,s=t.getAttribute("height"),a=t.getAttribute("width");let r=e.getBoundingClientRect().height,l=e.getBoundingClientRect().width;r-=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)+parseFloat(i),l-=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight);const o=Math.min(l/a||0,r/s),d=a*o||0,u=s*o||0;s>u&&s<r&&a>d&&a<l||s<u&&s<r&&a<d&&a<l?(t.style.width="",t.style.height=""):(t.style.width=`${d}px`,t.style.height=`${u}px`)},le=function(e){e.preventDefault(),P(this)},oe=function(e){e.target===f?V():e.target===b?G():(e.target===y||!$&&!x&&e.target.classList.contains("parvus__slide")&&u.docClose)&&R(),e.stopPropagation()},de=function(){return Array.prototype.slice.call(c.querySelectorAll(`${s.join(", ")}`)).filter((e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)))},ue=function(){de()[0].focus()},ce=function(e){const t=de(),n=t.indexOf(document.activeElement);"Tab"===e.code?e.shiftKey&&0===n?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||n!==t.length-1||(t[0].focus(),e.preventDefault()):"Escape"===e.code?(e.preventDefault(),R()):"ArrowLeft"===e.code?(e.preventDefault(),V()):"ArrowRight"===e.code&&(e.preventDefault(),G())},pe=function(){R()},ge=function(e){e.preventDefault(),e.stopPropagation(),x=!1,$=!1,S=!0,C.startX=e.pageX,C.startY=e.pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},he=function(e){e.preventDefault(),S&&(C.endX=e.pageX,C.endY=e.pageY,ye())},me=function(e){e.stopPropagation(),S=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(C.endX||C.endY)&&ie(),ne()},ve=function(e){e.stopPropagation(),x=!1,$=!1,S=!0,C.startX=e.touches[0].pageX,C.startY=e.touches[0].pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},fe=function(e){e.stopPropagation(),S&&(e.preventDefault(),C.endX=e.touches[0].pageX,C.endY=e.touches[0].pageY,ye())},be=function(e){e.stopPropagation(),S=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(C.endX||C.endY)&&ie(),ne()},ye=function(){const e=C.startX-C.endX,t=C.endY-C.startY,n=Math.abs(t);Math.abs(e)>0&&!$&&r[o].gallery.length>1?(r[o].slider.style.transform=`translate3d(${M-Math.round(e)}px, 0, 0)`,x=!0,$=!1):Math.abs(t)>0&&!x&&u.swipeClose&&(n<=96&&!I&&(g=1-n/100),c.classList.add("parvus--is-vertical-closing"),p.style.opacity=g,r[o].slider.style.transform=`translate3d(${M}px, ${Math.round(t)}px, 0)`,x=!1,$=!0)},we=function(){i.addEventListener("keydown",ce),i.addEventListener("resize",ae),u.scrollClose&&i.addEventListener("wheel",pe),i.addEventListener("popstate",R),c.addEventListener("click",oe),Le()&&(c.addEventListener("touchstart",ve),c.addEventListener("touchmove",fe),c.addEventListener("touchend",be)),c.addEventListener("mousedown",ge),c.addEventListener("mouseup",me),c.addEventListener("mousemove",he)},Ee=function(){i.removeEventListener("keydown",ce),i.removeEventListener("resize",ae),u.scrollClose&&i.removeEventListener("wheel",pe),i.removeEventListener("popstate",R),c.removeEventListener("click",oe),Le()&&(c.removeEventListener("touchstart",ve),c.removeEventListener("touchmove",fe),c.removeEventListener("touchend",be)),c.removeEventListener("mousedown",ge),c.removeEventListener("mouseup",me),c.removeEventListener("mousemove",he)},Ae=function(){return"false"===c.getAttribute("aria-hidden")},Le=function(){return"ontouchstart"in window};return Y(n),t.init=Y,t.open=P,t.close=R,t.select=K,t.previous=V,t.next=G,t.currentIndex=function(){return d},t.add=D,t.remove=O,t.destroy=function(){if(!c)return;Ae()&&R(),c.remove();document.querySelectorAll(".parvus-trigger").forEach((e=>{O(e)}));const e=new CustomEvent("destroy");c.dispatchEvent(e)},t.isOpen=Ae,t.on=function(e,t){c&&c.addEventListener(e,t)},t.off=function(e,t){c&&c.removeEventListener(e,t)},t}}));
{
"name": "parvus",
"version": "2.0.3",
"version": "2.0.4",
"description": "An accessible, open-source image lightbox with no dependencies.",

@@ -8,9 +8,8 @@ "main": "dist/js/parvus.js",

"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/preset-env": "^7.16.8",
"@babel/core": "^7.16.10",
"@babel/preset-env": "^7.16.10",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"core-js": "^3.20.2",
"node-sass": "^7.0.1",
"core-js": "^3.20.3",
"postcss": "^8.4.5",

@@ -22,2 +21,3 @@ "rollup": "^2.64.0",

"standard": "^16.0.4",
"sass": "^1.49.0",
"stylelint": "^14.2.0"

@@ -35,3 +35,4 @@ },

"CustomEvent",
"requestAnimationFrame"
"requestAnimationFrame",
"getComputedStyle"
]

@@ -38,0 +39,0 @@ },

@@ -65,2 +65,4 @@ # Parvus

or
```

@@ -76,2 +78,4 @@ yarn add parvus

Remember to include the corresponding SCSS or CSS file.
## Usage

@@ -78,0 +82,0 @@

@@ -20,3 +20,3 @@ // Default language

}
let groups = {}
const GROUPS = {}
let newGroup = null

@@ -170,2 +170,3 @@ let activeGroup = null

const getGroup = function getGroup (el) {
// Create a unique ID
const GROUP_ID = Math.floor(Math.random() * 10000)

@@ -202,9 +203,9 @@

if (!Object.prototype.hasOwnProperty.call(groups, newGroup)) {
groups[newGroup] = copyObject(GROUP_ATTS)
if (!Object.prototype.hasOwnProperty.call(GROUPS, newGroup)) {
GROUPS[newGroup] = copyObject(GROUP_ATTS)
}
// Check if element already exists
if (!groups[newGroup].gallery.includes(el)) {
groups[newGroup].gallery.push(el)
if (!GROUPS[newGroup].gallery.includes(el)) {
GROUPS[newGroup].gallery.push(el)

@@ -228,5 +229,5 @@ if (el.querySelector('img') !== null) {

if (isOpen() && newGroup === activeGroup) {
createSlide(el, groups[newGroup].gallery.indexOf(el))
createImage(el, groups[newGroup].gallery.indexOf(el), function () {
loadImage(groups[newGroup].gallery.indexOf(el))
createSlide(GROUPS[newGroup].gallery.indexOf(el))
createImage(el, GROUPS[newGroup].gallery.indexOf(el), function () {
loadImage(GROUPS[newGroup].gallery.indexOf(el))
})

@@ -255,3 +256,3 @@ updateConfig()

// Check if element exists
if (!groups[GROUP].gallery.includes(el)) {
if (!GROUPS[GROUP].gallery.includes(el)) {
throw new Error('Ups, I can\'t find the element.')

@@ -262,3 +263,3 @@ }

groups[GROUP].gallery.splice(groups[GROUP].gallery.indexOf(el), 1)
GROUPS[GROUP].gallery.splice(GROUPS[GROUP].gallery.indexOf(el), 1)

@@ -363,9 +364,9 @@ // Remove lightbox indicator icon if necessary

const createSlider = function createSlider () {
groups[activeGroup].slider = document.createElement('div')
groups[activeGroup].slider.className = 'parvus__slider'
GROUPS[activeGroup].slider = document.createElement('div')
GROUPS[activeGroup].slider.className = 'parvus__slider'
// Hide slider
groups[activeGroup].slider.setAttribute('aria-hidden', 'true')
GROUPS[activeGroup].slider.setAttribute('aria-hidden', 'true')
lightbox.appendChild(groups[activeGroup].slider)
lightbox.appendChild(GROUPS[activeGroup].slider)
}

@@ -377,6 +378,5 @@

* @param {HTMLElement} el
* @param {Number} index
*/
const createSlide = function createSlide (el, index) {
if (groups[activeGroup].sliderElements[index] !== undefined) {
const createSlide = function createSlide (index) {
if (GROUPS[activeGroup].sliderElements[index] !== undefined) {
// Nothing

@@ -397,13 +397,13 @@ } else {

groups[activeGroup].sliderElements[index] = SLIDER_ELEMENT
GROUPS[activeGroup].sliderElements[index] = SLIDER_ELEMENT
// Add slider element to slider
if (index === currentIndex) {
groups[activeGroup].slider.appendChild(SLIDER_ELEMENT)
GROUPS[activeGroup].slider.appendChild(SLIDER_ELEMENT)
}
if (index > currentIndex) {
groups[activeGroup].sliderElements[currentIndex].after(SLIDER_ELEMENT)
GROUPS[activeGroup].sliderElements[currentIndex].after(SLIDER_ELEMENT)
} else {
groups[activeGroup].sliderElements[currentIndex].before(SLIDER_ELEMENT)
GROUPS[activeGroup].sliderElements[currentIndex].before(SLIDER_ELEMENT)
}

@@ -426,7 +426,7 @@ }

// Check if element exists
if (!groups[activeGroup].gallery.includes(el)) {
if (!GROUPS[activeGroup].gallery.includes(el)) {
throw new Error('Ups, I can\'t find the element.')
}
currentIndex = groups[activeGroup].gallery.indexOf(el)
currentIndex = GROUPS[activeGroup].gallery.indexOf(el)

@@ -462,6 +462,6 @@ // Save user’s focus

createSlider()
createSlide(el, currentIndex)
createSlide(currentIndex)
// Show slider
groups[activeGroup].slider.setAttribute('aria-hidden', 'false')
GROUPS[activeGroup].slider.setAttribute('aria-hidden', 'false')

@@ -494,3 +494,3 @@ updateOffset()

// Add class for slider animation
groups[activeGroup].slider.classList.add('parvus__slider--animate')
GROUPS[activeGroup].slider.classList.add('parvus__slider--animate')
})

@@ -517,5 +517,5 @@

const IMAGE = groups[activeGroup].images[currentIndex]
const IMAGE = GROUPS[activeGroup].images[currentIndex]
const IMAGE_SIZE = IMAGE.getBoundingClientRect()
const THUMBNAIL = config.backFocus ? groups[activeGroup].gallery[currentIndex] : lastFocus
const THUMBNAIL = config.backFocus ? GROUPS[activeGroup].gallery[currentIndex] : lastFocus
const THUMBNAIL_SIZE = THUMBNAIL.getBoundingClientRect()

@@ -564,3 +564,3 @@

// Reenable the user’s focus
lastFocus = config.backFocus ? groups[activeGroup].gallery[currentIndex] : lastFocus
lastFocus = config.backFocus ? GROUPS[activeGroup].gallery[currentIndex] : lastFocus

@@ -579,8 +579,8 @@ lastFocus.focus({

// Reset groups
groups[activeGroup].slider.remove()
// Reset GROUPS
GROUPS[activeGroup].slider.remove()
groups[activeGroup].slider = null
groups[activeGroup].sliderElements = []
groups[activeGroup].images = []
GROUPS[activeGroup].slider = null
GROUPS[activeGroup].sliderElements = []
GROUPS[activeGroup].images = []
},

@@ -594,3 +594,3 @@ {

detail: {
source: groups[activeGroup].gallery[currentIndex]
source: GROUPS[activeGroup].gallery[currentIndex]
}

@@ -608,8 +608,8 @@ })

const preload = function preload (index) {
if (groups[activeGroup].gallery[index] === undefined) {
if (GROUPS[activeGroup].gallery[index] === undefined) {
return
}
createSlide(groups[activeGroup].gallery[index], index)
createImage(groups[activeGroup].gallery[index], index, function () {
createSlide(index)
createImage(GROUPS[activeGroup].gallery[index], index, function () {
loadImage(index)

@@ -625,4 +625,4 @@ })

const loadSlide = function loadSlide (index) {
groups[activeGroup].sliderElements[index].classList.add('parvus__slide--is-active')
groups[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'false')
GROUPS[activeGroup].sliderElements[index].classList.add('parvus__slide--is-active')
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'false')
}

@@ -633,11 +633,11 @@

*
* @param {HTMLElement} el
* @param {Number} index
* @param {HTMLElement} el
* @param {HTMLElement} container
* @param {Function} callback
*/
const createImage = function createImage (el, index, callback) {
if (groups[activeGroup].images[index] !== undefined) {
if (GROUPS[activeGroup].images[index] !== undefined) {
// Nothing
} else {
const container = groups[activeGroup].sliderElements[index].querySelector('div')
const container = GROUPS[activeGroup].sliderElements[index].querySelector('div')
const IMAGE = document.createElement('img')

@@ -667,3 +667,3 @@ const IMAGE_CONTAINER = document.createElement('div')

setImageDimension(groups[activeGroup].sliderElements[index], IMAGE)
setImageDimension(GROUPS[activeGroup].sliderElements[index], IMAGE)

@@ -697,3 +697,3 @@ if (callback && typeof callback === 'function') {

groups[activeGroup].images[index] = IMAGE
GROUPS[activeGroup].images[index] = IMAGE

@@ -723,2 +723,5 @@ container.appendChild(IMAGE_CONTAINER)

if (captionData !== null) {
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-labelledby', `parvus__caption-${index}`)
CAPTION_CONTAINER.id = `parvus__caption-${index}`
CAPTION_CONTAINER.innerHTML = `<p>${captionData}</p>`

@@ -738,5 +741,5 @@

const loadImage = function loadImage (index) {
const IMAGE = groups[activeGroup].images[index]
const IMAGE = GROUPS[activeGroup].images[index]
const IMAGE_SIZE = IMAGE.getBoundingClientRect()
const THUMBNAIL = groups[activeGroup].gallery[index]
const THUMBNAIL = GROUPS[activeGroup].gallery[index]
const THUMBNAIL_SIZE = THUMBNAIL.getBoundingClientRect()

@@ -769,5 +772,5 @@

*
* @param {Number} newIndex
* @param {Number} index
*/
const select = function select (newIndex) {
const select = function select (index) {
const OLD_INDEX = currentIndex

@@ -778,12 +781,12 @@

} else {
if (!newIndex && newIndex !== 0) {
if (!index && index !== 0) {
throw new Error('Ups, no slide specified.')
}
if (newIndex === currentIndex) {
throw new Error(`Ups, slide ${newIndex} is already selected.`)
if (index === currentIndex) {
throw new Error(`Ups, slide ${index} is already selected.`)
}
if (newIndex === -1 || newIndex >= groups[activeGroup].gallery.length) {
throw new Error(`Ups, I can't find slide ${newIndex}.`)
if (index === -1 || index >= GROUPS[activeGroup].gallery.length) {
throw new Error(`Ups, I can't find slide ${index}.`)
}

@@ -794,6 +797,6 @@ }

loadSlide(newIndex)
loadImage(newIndex)
loadSlide(index)
loadImage(index)
if (newIndex < OLD_INDEX) {
if (index < OLD_INDEX) {
currentIndex--

@@ -804,6 +807,6 @@

updateFocus('left')
preload(newIndex - 1)
preload(index - 1)
}
if (newIndex > OLD_INDEX) {
if (index > OLD_INDEX) {
currentIndex++

@@ -814,3 +817,3 @@

updateFocus('right')
preload(newIndex + 1)
preload(index + 1)
}

@@ -823,3 +826,3 @@

detail: {
source: groups[activeGroup].gallery[currentIndex]
source: GROUPS[activeGroup].gallery[currentIndex]
}

@@ -846,3 +849,3 @@ })

const next = function next () {
if (currentIndex < groups[activeGroup].gallery.length - 1) {
if (currentIndex < GROUPS[activeGroup].gallery.length - 1) {
select(currentIndex + 1)

@@ -859,4 +862,4 @@ }

const leaveSlide = function leaveSlide (index) {
groups[activeGroup].sliderElements[index].classList.remove('parvus__slide--is-active')
groups[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'true')
GROUPS[activeGroup].sliderElements[index].classList.remove('parvus__slide--is-active')
GROUPS[activeGroup].sliderElements[index].setAttribute('aria-hidden', 'true')
}

@@ -873,3 +876,3 @@

groups[activeGroup].slider.style.transform = `translate3d(${offset}px, 0, 0)`
GROUPS[activeGroup].slider.style.transform = `translate3d(${offset}px, 0, 0)`
offsetTmp = offset

@@ -884,3 +887,3 @@ }

const updateFocus = function updateFocus (dir) {
if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
closeButton.focus()

@@ -892,3 +895,3 @@ } else {

// If the last slide is displayed
} else if (currentIndex === groups[activeGroup].gallery.length - 1) {
} else if (currentIndex === GROUPS[activeGroup].gallery.length - 1) {
previousButton.focus()

@@ -910,3 +913,3 @@ } else {

const updateCounter = function updateCounter () {
counter.textContent = `${currentIndex + 1}/${groups[activeGroup].gallery.length}`
counter.textContent = `${currentIndex + 1}/${GROUPS[activeGroup].gallery.length}`
}

@@ -939,3 +942,3 @@

previous()
} else if (isDraggingX && MOVEMENT_X < 0 && MOVEMENT_X_DISTANCE >= config.threshold && currentIndex !== groups[activeGroup].gallery.length - 1) {
} else if (isDraggingX && MOVEMENT_X < 0 && MOVEMENT_X_DISTANCE >= config.threshold && currentIndex !== GROUPS[activeGroup].gallery.length - 1) {
next()

@@ -962,8 +965,8 @@ } else if (isDraggingY && MOVEMENT_Y_DISTANCE > 0) {

const updateConfig = function updateConfig () {
if ((config.swipeClose && !groups[activeGroup].slider.classList.contains('parvus__slider--is-draggable')) || (groups[activeGroup].gallery.length > 1 && !groups[activeGroup].slider.classList.contains('parvus__slider--is-draggable'))) {
groups[activeGroup].slider.classList.add('parvus__slider--is-draggable')
if ((config.swipeClose && !GROUPS[activeGroup].slider.classList.contains('parvus__slider--is-draggable')) || (GROUPS[activeGroup].gallery.length > 1 && !GROUPS[activeGroup].slider.classList.contains('parvus__slider--is-draggable'))) {
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-draggable')
}
// Hide buttons if necessary
if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
previousButton.setAttribute('aria-hidden', 'true')

@@ -981,3 +984,3 @@ previousButton.disabled = true

// If the last slide is displayed
} else if (currentIndex === groups[activeGroup].gallery.length - 1) {
} else if (currentIndex === GROUPS[activeGroup].gallery.length - 1) {
previousButton.setAttribute('aria-hidden', 'false')

@@ -996,3 +999,3 @@ previousButton.disabled = false

// Hide counter if necessary
if (groups[activeGroup].gallery.length === 1) {
if (GROUPS[activeGroup].gallery.length === 1) {
counter.setAttribute('aria-hidden', 'true')

@@ -1013,3 +1016,6 @@ } else {

BROWSER_WINDOW.requestAnimationFrame(() => {
setImageDimension(groups[activeGroup].sliderElements[currentIndex], groups[activeGroup].images[currentIndex])
GROUPS[activeGroup].sliderElements.forEach((slide, index) => {
setImageDimension(slide, GROUPS[activeGroup].images[index])
})
updateOffset()

@@ -1031,4 +1037,4 @@

const captionRec = slideEl.querySelector('.parvus__caption') !== null ? slideEl.querySelector('.parvus__caption').getBoundingClientRect().height : 0
const srcHeight = imageEl.naturalHeight
const srcWidth = imageEl.naturalWidth
const srcHeight = imageEl.getAttribute('height')
const srcWidth = imageEl.getAttribute('width')

@@ -1041,11 +1047,24 @@ let maxHeight = slideEl.getBoundingClientRect().height

if (imageEl.naturalHeight < maxHeight && imageEl.naturalWidth < maxWidth) {
maxHeight = imageEl.naturalHeight
maxWidth = imageEl.naturalWidth
}
const ratio = Math.min(maxWidth / srcWidth || 0, maxHeight / srcHeight)
imageEl.style.width = `${srcWidth * ratio || 0}px`
imageEl.style.height = `${srcHeight * ratio || 0}px`
const newWidth = srcWidth * ratio || 0
const newHeight = srcHeight * ratio || 0
if ((
srcHeight > newHeight &&
srcHeight < maxHeight &&
srcWidth > newWidth &&
srcWidth < maxWidth
) || (
srcHeight < newHeight &&
srcHeight < maxHeight &&
srcWidth < newWidth &&
srcWidth < maxWidth
)) {
imageEl.style.width = ''
imageEl.style.height = ''
} else {
imageEl.style.width = `${newWidth}px`
imageEl.style.height = `${newHeight}px`
}
}

@@ -1085,3 +1104,3 @@

const getFocusableChildren = function getFocusableChildren () {
return Array.prototype.slice.call(lightbox.querySelectorAll(`${FOCUSABLE_ELEMENTS.join(', ')}`)).filter(function (child) {
return Array.prototype.slice.call(lightbox.querySelectorAll(`${FOCUSABLE_ELEMENTS.join(', ')}`)).filter((child) => {
return !!(

@@ -1165,4 +1184,4 @@ child.offsetWidth ||

groups[activeGroup].slider.classList.add('parvus__slider--is-dragging')
groups[activeGroup].slider.style.willChange = 'transform'
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-dragging')
GROUPS[activeGroup].slider.style.willChange = 'transform'
}

@@ -1194,4 +1213,4 @@

groups[activeGroup].slider.classList.remove('parvus__slider--is-dragging')
groups[activeGroup].slider.style.willChange = 'auto'
GROUPS[activeGroup].slider.classList.remove('parvus__slider--is-dragging')
GROUPS[activeGroup].slider.style.willChange = 'auto'

@@ -1220,4 +1239,4 @@ if (drag.endX || drag.endY) {

groups[activeGroup].slider.classList.add('parvus__slider--is-dragging')
groups[activeGroup].slider.style.willChange = 'transform'
GROUPS[activeGroup].slider.classList.add('parvus__slider--is-dragging')
GROUPS[activeGroup].slider.style.willChange = 'transform'
}

@@ -1251,4 +1270,4 @@

groups[activeGroup].slider.classList.remove('parvus__slider--is-dragging')
groups[activeGroup].slider.style.willChange = 'auto'
GROUPS[activeGroup].slider.classList.remove('parvus__slider--is-dragging')
GROUPS[activeGroup].slider.style.willChange = 'auto'

@@ -1271,5 +1290,5 @@ if (drag.endX || drag.endY) {

if (Math.abs(MOVEMENT_X) > 0 && !isDraggingY && groups[activeGroup].gallery.length > 1) {
if (Math.abs(MOVEMENT_X) > 0 && !isDraggingY && GROUPS[activeGroup].gallery.length > 1) {
// Horizontal swipe
groups[activeGroup].slider.style.transform = `translate3d(${offsetTmp - Math.round(MOVEMENT_X)}px, 0, 0)`
GROUPS[activeGroup].slider.style.transform = `translate3d(${offsetTmp - Math.round(MOVEMENT_X)}px, 0, 0)`

@@ -1287,3 +1306,3 @@ isDraggingX = true

groups[activeGroup].slider.style.transform = `translate3d(${offsetTmp}px, ${Math.round(MOVEMENT_Y)}px, 0)`
GROUPS[activeGroup].slider.style.transform = `translate3d(${offsetTmp}px, ${Math.round(MOVEMENT_Y)}px, 0)`

@@ -1290,0 +1309,0 @@ isDraggingX = false

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc