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 1.4.0 to 1.4.1

11

dist/js/parvus.esm.js

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

* @author de Oostfreese
* @version 1.4.0
* @version 1.4.1
* @url https://github.com/deoostfreese/parvus

@@ -11,2 +11,3 @@ *

*/
function Parvus(userOptions) {

@@ -207,3 +208,3 @@ /**

if (GROUPS[newGroup].gallery.indexOf(el) === -1) {
if (!GROUPS[newGroup].gallery.includes(el)) {
GROUPS[newGroup].gallery.push(el);

@@ -248,3 +249,3 @@

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

@@ -375,3 +376,3 @@ } // TODO: Remove elements dynamically

if (GROUPS[activeGroup].gallery.indexOf(el) === -1) {
if (!GROUPS[activeGroup].gallery.includes(el)) {
throw new Error('Ups, I can\'t find the element.');

@@ -1232,2 +1233,2 @@ }

export default Parvus;
export { Parvus as default };

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

* @author de Oostfreese
* @version 1.4.0
* @version 1.4.1
* @url https://github.com/deoostfreese/parvus

@@ -11,2 +11,3 @@ *

*/
function e(t){const n=window,i=["button:not([disabled]):not([inert])",'[tabindex]:not([tabindex^="-"]):not([inert])'],r={gallery:[],slider:null,sliderElements:[]},s={};let a=null,l=null,o=0,d={},u=null,c=null,p=1,g=null,h=null,m=null,v=null,f=0,b=0,y=0,w=0,E={},L=!1,A=!1,_=!1,x=null,C=null,$=null,T=!1,B=null,S=!0;const M=window.matchMedia("(prefers-reduced-motion)"),I=function(){M.matches?(S=!0,B=d.reducedTransitionDuration):(S=!1,B=d.transitionDuration)};M.addEventListener("change",I);const q=function(e){d=function(e){return{selector:".lightbox",gallerySelector:null,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>',lang:"en",i18n:{en:{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"}},fileTypes:/\.(png|jpe?g|webp|avif|svg)(\?.*)?$/i,...e}}(e);if(document.querySelectorAll(d.selector).length)if(I(),u||F(),null!==d.gallerySelector){document.querySelectorAll(d.gallerySelector).forEach(((e,t)=>{const n=t;e.querySelectorAll(d.selector).forEach((e=>{e.setAttribute("data-group",`parvus-gallery-${n}`),Y(e)}))}));document.querySelectorAll(`${d.selector}:not(.parvus-trigger)`).forEach((e=>{Y(e)}))}else{document.querySelectorAll(d.selector).forEach((e=>{Y(e)}))}},X=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")},Y=function(e){if(!("A"===e.tagName&&e.hasAttribute("href")&&e.href.match(d.fileTypes)||"BUTTON"===e.tagName&&e.hasAttribute("data-target")&&e.getAttribute("data-target").match(d.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: ${d.fileTypes}.`);var t;if(a=X(e),Object.prototype.hasOwnProperty.call(s,a)||(s[a]=(t=r,JSON.parse(JSON.stringify(t)))),-1!==s[a].gallery.indexOf(e))throw new Error("Ups, element already added.");if(s[a].gallery.push(e),null!==e.querySelector("img")){const t=document.createElement("div");e.classList.add("parvus-zoom"),t.className="parvus-zoom__indicator",t.innerHTML=d.lightboxIndicatorIcon,e.appendChild(t)}e.classList.add("parvus-trigger"),e.addEventListener("click",ne),fe()&&a===l&&(N(e,s[a].gallery.indexOf(e)),P(s[a].gallery.indexOf(e)),ee(),V(),G())},k=function(e){if(fe()||!u||!e||!e.hasAttribute("data-group"))return;const t=X(e);if(-1===s[t].gallery.indexOf(e))throw new Error("Ups, I can't find the element.");if(s[t].gallery.splice(s[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",ne),e.classList.remove("parvus-trigger")},F=function(){u=document.createElement("div"),u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-hidden","true"),u.setAttribute("tabindex","-1"),u.setAttribute("aria-label",d.i18n[d.lang].lightboxLabel),u.classList.add("parvus"),c=document.createElement("div"),c.classList.add("parvus__overlay"),c.style.opacity=0,u.appendChild(c),m=document.createElement("button"),m.className="parvus__btn parvus__btn--close",m.setAttribute("type","button"),m.setAttribute("aria-label",d.i18n[d.lang].closeButtonLabel),m.innerHTML=d.closeButtonIcon,u.appendChild(m),g=document.createElement("button"),g.className="parvus__btn parvus__btn--previous",g.setAttribute("type","button"),g.setAttribute("aria-label",d.i18n[d.lang].previousButtonLabel),g.innerHTML=d.previousButtonIcon,u.appendChild(g),h=document.createElement("button"),h.className="parvus__btn parvus__btn--next",h.setAttribute("type","button"),h.setAttribute("aria-label",d.i18n[d.lang].nextButtonLabel),h.innerHTML=d.nextButtonIcon,u.appendChild(h),v=document.createElement("div"),v.className="parvus__counter",u.appendChild(v),document.body.appendChild(u)},N=function(e,t){const n=document.createElement("div"),i=document.createElement("div");n.className="parvus__slide",n.style.position="absolute",n.style.left=100*t+"%",n.setAttribute("aria-hidden","true"),U(e,i),n.appendChild(i),s[l].sliderElements[t]=n,t===o&&s[l].slider.appendChild(n),t>o?s[l].sliderElements[o].after(n):s[l].sliderElements[o].before(n)},O=function(e){if(!u||!e||!e.classList.contains("parvus-trigger")||fe())return;if(l=X(e),-1===s[l].gallery.indexOf(e))throw new Error("Ups, I can't find the element.");o=s[l].gallery.indexOf(e),x=document.activeElement;const t=window.location.href;history.pushState({parvus:"close"},"Image",t),me();document.querySelectorAll('body > *:not([aria-hidden="true"])').forEach((e=>{e.setAttribute("aria-hidden","true"),e.classList.add("parvus-hidden")})),u.classList.add("parvus--is-opening"),u.setAttribute("aria-hidden","false"),s[l].slider=document.createElement("div"),s[l].slider.className="parvus__slider",s[l].slider.setAttribute("aria-hidden","true"),u.appendChild(s[l].slider),N(e,o),s[l].slider.setAttribute("aria-hidden","false"),K(),ee(),G(),se(),H(o),P(o),requestAnimationFrame((()=>{u.classList.remove("parvus--is-opening"),c.style.opacity=1,c.style.transition=`opacity ${B}ms ${d.transitionTimingFunction}`,c.style.willChange="opacity"})),c.addEventListener("transitionend",(()=>{z(o+1),z(o-1)})),s[l].slider.classList.add("parvus__slider--animate");const n=new CustomEvent("open",{detail:{source:e}});u.dispatchEvent(n)},D=function(){if(!fe())throw new Error("Ups, I'm already closed.");const e=s[l].sliderElements[o].querySelector("img"),t=e.getBoundingClientRect(),n=(d.backFocus?s[l].gallery[o]:x).getBoundingClientRect();ve(),Q(),null!==history.state&&"close"===history.state.parvus&&history.back();document.querySelectorAll(".parvus-hidden").forEach((e=>{e.removeAttribute("aria-hidden"),e.classList.remove("parvus-hidden")})),u.classList.add("parvus--is-closing"),requestAnimationFrame((()=>{f=n.width/t.width,b=n.height/t.height,y=n.left-t.left,w=n.top-t.top,e.style.transform=`translate(${y}px, ${w}px) scale(${f}, ${b})`,e.style.opacity=0,e.style.transition=`transform ${B}ms ${d.transitionTimingFunction}, opacity ${B}ms ${d.transitionTimingFunction} ${B/2}ms`,c.style.opacity=0,c.style.transition=`opacity ${B}ms ${d.transitionTimingFunction}`,c.style.willChange="auto"})),c.addEventListener("transitionend",(()=>{J(o),x=d.backFocus?s[l].gallery[o]:x,x.focus({preventScroll:!0}),u.setAttribute("aria-hidden","true"),u.classList.remove("parvus--is-closing"),u.classList.remove("parvus--is-vertical-closing"),s[l].slider.remove(),e.style.transform=""}),{once:!0});const i=new CustomEvent("close",{detail:{source:s[l].gallery[o]}});u.dispatchEvent(i)},z=function(e){void 0!==s[l].gallery[e]&&(N(s[l].gallery[e],e),P(e))},H=function(e){s[l].sliderElements[e].classList.add("parvus__slide--is-active"),s[l].sliderElements[e].setAttribute("aria-hidden","false")},U=function(e,t){const n=document.createElement("img"),i=document.createElement("figure"),r=document.createElement("figcaption"),s=e.querySelector("img"),a=document.createElement("div");a.className="parvus__loader",a.setAttribute("role","progressbar"),a.setAttribute("aria-label",d.i18n[d.lang].lightboxLoadingIndicatorLabel),t.appendChild(a),n.onload=()=>{t.removeChild(a),n.setAttribute("width",n.naturalWidth),n.setAttribute("height",n.naturalHeight)},"A"===e.tagName?(n.setAttribute("src",e.href),n.alt=s?s.alt||"":e.getAttribute("data-alt")||""):(n.alt=e.getAttribute("data-alt")||"",n.setAttribute("src",e.getAttribute("data-target"))),e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&n.setAttribute("srcset",e.getAttribute("data-srcset")),n.style.opacity=0,i.appendChild(n),e.hasAttribute("data-caption")&&""!==e.getAttribute("data-caption")&&(r.innerHTML=e.getAttribute("data-caption"),i.appendChild(r)),t.appendChild(i)},P=function(e){const t=s[l].sliderElements[e].querySelector("img"),n=t.getBoundingClientRect(),i=s[l].gallery[e].getBoundingClientRect();u.classList.contains("parvus--is-opening")?(f=i.width/n.width,b=i.height/n.height,y=i.left-n.left,w=i.top-n.top,requestAnimationFrame((()=>{t.style.transform=`translate(${y}px, ${w}px) scale(${f}, ${b})`,t.style.transition="transform 0s, opacity 0s",requestAnimationFrame((()=>{t.style.transform="",t.style.opacity=1,t.style.transition=`transform ${B}ms ${d.transitionTimingFunction}, opacity ${B/2}ms ${d.transitionTimingFunction}`}))}))):t.style.opacity=1},R=function(e){const t=o;if(!fe())throw new Error("Ups, I'm closed.");if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===o)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=s[l].gallery.length)throw new Error(`Ups, I can't find slide ${e}.`);J(t),H(e),P(e),e<t&&(o--,K(),ee(),V("left"),z(e-1)),e>t&&(o++,K(),ee(),V("right"),z(e+1)),G();const n=new CustomEvent("select",{detail:{source:s[l].gallery[o]}});u.dispatchEvent(n)},j=function(){o>0&&R(o-1)},W=function(){o<s[l].gallery.length-1&&R(o+1)},J=function(e){s[l].sliderElements[e].classList.remove("parvus__slide--is-active"),s[l].sliderElements[e].setAttribute("aria-hidden","true")},K=function(){l=null!==l?l:a,C=-o*u.offsetWidth,s[l].slider.style.transform=`translate3d(${C}px, 0, 0)`,$=C},V=function(e){1===s[l].gallery.length?m.focus():0===o?h.focus():o===s[l].gallery.length-1||"left"===e?g.focus():h.focus()},G=function(){v.textContent=`${o+1}/${s[l].gallery.length}`},Q=function(){E={startX:0,endX:0,startY:0,endY:0}},Z=function(){const e=E.endX-E.startX,t=E.endY-E.startY,n=Math.abs(e),i=Math.abs(t);L&&e>0&&n>=d.threshold&&o>0?j():L&&e<0&&n>=d.threshold&&o!==s[l].gallery.length-1?W():A&&i>0?i>=d.threshold&&d.swipeClose?D():(c.style.opacity=1,u.classList.remove("parvus--is-vertical-closing"),K()):K()},ee=function(){(d.swipeClose&&!s[l].slider.classList.contains("parvus__slider--is-draggable")||s[l].gallery.length>1&&!s[l].slider.classList.contains("parvus__slider--is-draggable"))&&s[l].slider.classList.add("parvus__slider--is-draggable"),1===s[l].gallery.length?(g.setAttribute("aria-hidden","true"),g.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0):0===o?(g.setAttribute("aria-hidden","true"),g.disabled=!0,h.setAttribute("aria-hidden","false"),h.disabled=!1):o===s[l].gallery.length-1?(g.setAttribute("aria-hidden","false"),g.disabled=!1,h.setAttribute("aria-hidden","true"),h.disabled=!0):(g.setAttribute("aria-hidden","false"),g.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1),1===s[l].gallery.length?v.setAttribute("aria-hidden","true"):v.setAttribute("aria-hidden","false")},te=function(){T||(T=!0,n.requestAnimationFrame((()=>{K(),T=!1})))},ne=function(e){e.preventDefault(),O(this)},ie=function(e){e.target===g?j():e.target===h?W():(e.target===m||!A&&!L&&e.target.classList.contains("parvus__slide")&&d.docClose)&&D(),e.stopPropagation()},re=function(){return Array.prototype.slice.call(u.querySelectorAll(`${i.join(", ")}`)).filter((function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}))},se=function(){re()[0].focus()},ae=function(e){const t=re(),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(),D()):"ArrowLeft"===e.code?(e.preventDefault(),j()):"ArrowRight"===e.code&&(e.preventDefault(),W())},le=function(){D()},oe=function(e){e.preventDefault(),e.stopPropagation(),L=!1,A=!1,_=!0,E.startX=e.pageX,E.startY=e.pageY,s[l].slider.classList.add("parvus__slider--is-dragging"),s[l].slider.style.willChange="transform"},de=function(e){e.preventDefault(),_&&(E.endX=e.pageX,E.endY=e.pageY,he())},ue=function(e){e.stopPropagation(),_=!1,s[l].slider.classList.remove("parvus__slider--is-dragging"),s[l].slider.style.willChange="auto",(E.endX||E.endY)&&Z(),Q()},ce=function(e){e.stopPropagation(),L=!1,A=!1,_=!0,E.startX=e.touches[0].pageX,E.startY=e.touches[0].pageY,s[l].slider.classList.add("parvus__slider--is-dragging"),s[l].slider.style.willChange="transform"},pe=function(e){e.stopPropagation(),_&&(e.preventDefault(),E.endX=e.touches[0].pageX,E.endY=e.touches[0].pageY,he())},ge=function(e){e.stopPropagation(),_=!1,s[l].slider.classList.remove("parvus__slider--is-dragging"),s[l].slider.style.willChange="auto",(E.endX||E.endY)&&Z(),Q()},he=function(){const e=E.startX-E.endX,t=E.endY-E.startY,n=Math.abs(t);Math.abs(e)>0&&!A&&s[l].gallery.length>1?(s[l].slider.style.transform=`translate3d(${$-Math.round(e)}px, 0, 0)`,L=!0,A=!1):Math.abs(t)>0&&!L&&d.swipeClose&&(n<=96&&!S&&(p=1-n/100),u.classList.add("parvus--is-vertical-closing"),c.style.opacity=p,s[l].slider.style.transform=`translate3d(${$}px, ${Math.round(t)}px, 0)`,L=!1,A=!0)},me=function(){n.addEventListener("keydown",ae),n.addEventListener("resize",te),d.scrollClose&&n.addEventListener("wheel",le),n.addEventListener("popstate",D),u.addEventListener("click",ie),be()&&(u.addEventListener("touchstart",ce),u.addEventListener("touchmove",pe),u.addEventListener("touchend",ge)),u.addEventListener("mousedown",oe),u.addEventListener("mouseup",ue),u.addEventListener("mousemove",de)},ve=function(){n.removeEventListener("keydown",ae),n.removeEventListener("resize",te),d.scrollClose&&n.removeEventListener("wheel",le),n.removeEventListener("popstate",D),u.removeEventListener("click",ie),be()&&(u.removeEventListener("touchstart",ce),u.removeEventListener("touchmove",pe),u.removeEventListener("touchend",ge)),u.removeEventListener("mousedown",oe),u.removeEventListener("mouseup",ue),u.removeEventListener("mousemove",de)},fe=function(){return"false"===u.getAttribute("aria-hidden")},be=function(){return"ontouchstart"in window};return q(t),e.init=q,e.open=O,e.close=D,e.select=R,e.previous=j,e.next=W,e.currentIndex=function(){return o},e.add=Y,e.remove=k,e.destroy=function(){if(!u)return;fe()&&D(),u.remove();document.querySelectorAll(".parvus-trigger").forEach((e=>{k(e)}));const e=new CustomEvent("destroy");u.dispatchEvent(e)},e.isOpen=fe,e.on=function(e,t){u&&u.addEventListener(e,t)},e.off=function(e,t){u&&u.removeEventListener(e,t)},e}export default e;
function e(t){const n=window,i=["button:not([disabled]):not([inert])",'[tabindex]:not([tabindex^="-"]):not([inert])'],s={gallery:[],slider:null,sliderElements:[]},r={};let a=null,l=null,o=0,d={},u=null,c=null,p=1,g=null,h=null,m=null,v=null,f=0,b=0,y=0,w=0,E={},L=!1,A=!1,_=!1,C=null,x=null,$=null,T=!1,B=null,S=!0;const M=window.matchMedia("(prefers-reduced-motion)"),I=function(){M.matches?(S=!0,B=d.reducedTransitionDuration):(S=!1,B=d.transitionDuration)};M.addEventListener("change",I);const q=function(e){d=function(e){return{selector:".lightbox",gallerySelector:null,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>',lang:"en",i18n:{en:{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"}},fileTypes:/\.(png|jpe?g|webp|avif|svg)(\?.*)?$/i,...e}}(e);if(document.querySelectorAll(d.selector).length)if(I(),u||F(),null!==d.gallerySelector){document.querySelectorAll(d.gallerySelector).forEach(((e,t)=>{const n=t;e.querySelectorAll(d.selector).forEach((e=>{e.setAttribute("data-group",`parvus-gallery-${n}`),Y(e)}))}));document.querySelectorAll(`${d.selector}:not(.parvus-trigger)`).forEach((e=>{Y(e)}))}else{document.querySelectorAll(d.selector).forEach((e=>{Y(e)}))}},X=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")},Y=function(e){if(!("A"===e.tagName&&e.hasAttribute("href")&&e.href.match(d.fileTypes)||"BUTTON"===e.tagName&&e.hasAttribute("data-target")&&e.getAttribute("data-target").match(d.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: ${d.fileTypes}.`);var t;if(a=X(e),Object.prototype.hasOwnProperty.call(r,a)||(r[a]=(t=s,JSON.parse(JSON.stringify(t)))),r[a].gallery.includes(e))throw new Error("Ups, element already added.");if(r[a].gallery.push(e),null!==e.querySelector("img")){const t=document.createElement("div");e.classList.add("parvus-zoom"),t.className="parvus-zoom__indicator",t.innerHTML=d.lightboxIndicatorIcon,e.appendChild(t)}e.classList.add("parvus-trigger"),e.addEventListener("click",ne),fe()&&a===l&&(N(e,r[a].gallery.indexOf(e)),P(r[a].gallery.indexOf(e)),ee(),V(),G())},k=function(e){if(fe()||!u||!e||!e.hasAttribute("data-group"))return;const t=X(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",ne),e.classList.remove("parvus-trigger")},F=function(){u=document.createElement("div"),u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-hidden","true"),u.setAttribute("tabindex","-1"),u.setAttribute("aria-label",d.i18n[d.lang].lightboxLabel),u.classList.add("parvus"),c=document.createElement("div"),c.classList.add("parvus__overlay"),c.style.opacity=0,u.appendChild(c),m=document.createElement("button"),m.className="parvus__btn parvus__btn--close",m.setAttribute("type","button"),m.setAttribute("aria-label",d.i18n[d.lang].closeButtonLabel),m.innerHTML=d.closeButtonIcon,u.appendChild(m),g=document.createElement("button"),g.className="parvus__btn parvus__btn--previous",g.setAttribute("type","button"),g.setAttribute("aria-label",d.i18n[d.lang].previousButtonLabel),g.innerHTML=d.previousButtonIcon,u.appendChild(g),h=document.createElement("button"),h.className="parvus__btn parvus__btn--next",h.setAttribute("type","button"),h.setAttribute("aria-label",d.i18n[d.lang].nextButtonLabel),h.innerHTML=d.nextButtonIcon,u.appendChild(h),v=document.createElement("div"),v.className="parvus__counter",u.appendChild(v),document.body.appendChild(u)},N=function(e,t){const n=document.createElement("div"),i=document.createElement("div");n.className="parvus__slide",n.style.position="absolute",n.style.left=100*t+"%",n.setAttribute("aria-hidden","true"),U(e,i),n.appendChild(i),r[l].sliderElements[t]=n,t===o&&r[l].slider.appendChild(n),t>o?r[l].sliderElements[o].after(n):r[l].sliderElements[o].before(n)},D=function(e){if(!u||!e||!e.classList.contains("parvus-trigger")||fe())return;if(l=X(e),!r[l].gallery.includes(e))throw new Error("Ups, I can't find the element.");o=r[l].gallery.indexOf(e),C=document.activeElement;const t=window.location.href;history.pushState({parvus:"close"},"Image",t),me();document.querySelectorAll('body > *:not([aria-hidden="true"])').forEach((e=>{e.setAttribute("aria-hidden","true"),e.classList.add("parvus-hidden")})),u.classList.add("parvus--is-opening"),u.setAttribute("aria-hidden","false"),r[l].slider=document.createElement("div"),r[l].slider.className="parvus__slider",r[l].slider.setAttribute("aria-hidden","true"),u.appendChild(r[l].slider),N(e,o),r[l].slider.setAttribute("aria-hidden","false"),K(),ee(),G(),re(),H(o),P(o),requestAnimationFrame((()=>{u.classList.remove("parvus--is-opening"),c.style.opacity=1,c.style.transition=`opacity ${B}ms ${d.transitionTimingFunction}`,c.style.willChange="opacity"})),c.addEventListener("transitionend",(()=>{z(o+1),z(o-1)})),r[l].slider.classList.add("parvus__slider--animate");const n=new CustomEvent("open",{detail:{source:e}});u.dispatchEvent(n)},O=function(){if(!fe())throw new Error("Ups, I'm already closed.");const e=r[l].sliderElements[o].querySelector("img"),t=e.getBoundingClientRect(),n=(d.backFocus?r[l].gallery[o]:C).getBoundingClientRect();ve(),Q(),null!==history.state&&"close"===history.state.parvus&&history.back();document.querySelectorAll(".parvus-hidden").forEach((e=>{e.removeAttribute("aria-hidden"),e.classList.remove("parvus-hidden")})),u.classList.add("parvus--is-closing"),requestAnimationFrame((()=>{f=n.width/t.width,b=n.height/t.height,y=n.left-t.left,w=n.top-t.top,e.style.transform=`translate(${y}px, ${w}px) scale(${f}, ${b})`,e.style.opacity=0,e.style.transition=`transform ${B}ms ${d.transitionTimingFunction}, opacity ${B}ms ${d.transitionTimingFunction} ${B/2}ms`,c.style.opacity=0,c.style.transition=`opacity ${B}ms ${d.transitionTimingFunction}`,c.style.willChange="auto"})),c.addEventListener("transitionend",(()=>{J(o),C=d.backFocus?r[l].gallery[o]:C,C.focus({preventScroll:!0}),u.setAttribute("aria-hidden","true"),u.classList.remove("parvus--is-closing"),u.classList.remove("parvus--is-vertical-closing"),r[l].slider.remove(),e.style.transform=""}),{once:!0});const i=new CustomEvent("close",{detail:{source:r[l].gallery[o]}});u.dispatchEvent(i)},z=function(e){void 0!==r[l].gallery[e]&&(N(r[l].gallery[e],e),P(e))},H=function(e){r[l].sliderElements[e].classList.add("parvus__slide--is-active"),r[l].sliderElements[e].setAttribute("aria-hidden","false")},U=function(e,t){const n=document.createElement("img"),i=document.createElement("figure"),s=document.createElement("figcaption"),r=e.querySelector("img"),a=document.createElement("div");a.className="parvus__loader",a.setAttribute("role","progressbar"),a.setAttribute("aria-label",d.i18n[d.lang].lightboxLoadingIndicatorLabel),t.appendChild(a),n.onload=()=>{t.removeChild(a),n.setAttribute("width",n.naturalWidth),n.setAttribute("height",n.naturalHeight)},"A"===e.tagName?(n.setAttribute("src",e.href),n.alt=r?r.alt||"":e.getAttribute("data-alt")||""):(n.alt=e.getAttribute("data-alt")||"",n.setAttribute("src",e.getAttribute("data-target"))),e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&n.setAttribute("srcset",e.getAttribute("data-srcset")),n.style.opacity=0,i.appendChild(n),e.hasAttribute("data-caption")&&""!==e.getAttribute("data-caption")&&(s.innerHTML=e.getAttribute("data-caption"),i.appendChild(s)),t.appendChild(i)},P=function(e){const t=r[l].sliderElements[e].querySelector("img"),n=t.getBoundingClientRect(),i=r[l].gallery[e].getBoundingClientRect();u.classList.contains("parvus--is-opening")?(f=i.width/n.width,b=i.height/n.height,y=i.left-n.left,w=i.top-n.top,requestAnimationFrame((()=>{t.style.transform=`translate(${y}px, ${w}px) scale(${f}, ${b})`,t.style.transition="transform 0s, opacity 0s",requestAnimationFrame((()=>{t.style.transform="",t.style.opacity=1,t.style.transition=`transform ${B}ms ${d.transitionTimingFunction}, opacity ${B/2}ms ${d.transitionTimingFunction}`}))}))):t.style.opacity=1},R=function(e){const t=o;if(!fe())throw new Error("Ups, I'm closed.");if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===o)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=r[l].gallery.length)throw new Error(`Ups, I can't find slide ${e}.`);J(t),H(e),P(e),e<t&&(o--,K(),ee(),V("left"),z(e-1)),e>t&&(o++,K(),ee(),V("right"),z(e+1)),G();const n=new CustomEvent("select",{detail:{source:r[l].gallery[o]}});u.dispatchEvent(n)},j=function(){o>0&&R(o-1)},W=function(){o<r[l].gallery.length-1&&R(o+1)},J=function(e){r[l].sliderElements[e].classList.remove("parvus__slide--is-active"),r[l].sliderElements[e].setAttribute("aria-hidden","true")},K=function(){l=null!==l?l:a,x=-o*u.offsetWidth,r[l].slider.style.transform=`translate3d(${x}px, 0, 0)`,$=x},V=function(e){1===r[l].gallery.length?m.focus():0===o?h.focus():o===r[l].gallery.length-1||"left"===e?g.focus():h.focus()},G=function(){v.textContent=`${o+1}/${r[l].gallery.length}`},Q=function(){E={startX:0,endX:0,startY:0,endY:0}},Z=function(){const e=E.endX-E.startX,t=E.endY-E.startY,n=Math.abs(e),i=Math.abs(t);L&&e>0&&n>=d.threshold&&o>0?j():L&&e<0&&n>=d.threshold&&o!==r[l].gallery.length-1?W():A&&i>0?i>=d.threshold&&d.swipeClose?O():(c.style.opacity=1,u.classList.remove("parvus--is-vertical-closing"),K()):K()},ee=function(){(d.swipeClose&&!r[l].slider.classList.contains("parvus__slider--is-draggable")||r[l].gallery.length>1&&!r[l].slider.classList.contains("parvus__slider--is-draggable"))&&r[l].slider.classList.add("parvus__slider--is-draggable"),1===r[l].gallery.length?(g.setAttribute("aria-hidden","true"),g.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0):0===o?(g.setAttribute("aria-hidden","true"),g.disabled=!0,h.setAttribute("aria-hidden","false"),h.disabled=!1):o===r[l].gallery.length-1?(g.setAttribute("aria-hidden","false"),g.disabled=!1,h.setAttribute("aria-hidden","true"),h.disabled=!0):(g.setAttribute("aria-hidden","false"),g.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1),1===r[l].gallery.length?v.setAttribute("aria-hidden","true"):v.setAttribute("aria-hidden","false")},te=function(){T||(T=!0,n.requestAnimationFrame((()=>{K(),T=!1})))},ne=function(e){e.preventDefault(),D(this)},ie=function(e){e.target===g?j():e.target===h?W():(e.target===m||!A&&!L&&e.target.classList.contains("parvus__slide")&&d.docClose)&&O(),e.stopPropagation()},se=function(){return Array.prototype.slice.call(u.querySelectorAll(`${i.join(", ")}`)).filter((function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}))},re=function(){se()[0].focus()},ae=function(e){const t=se(),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(),O()):"ArrowLeft"===e.code?(e.preventDefault(),j()):"ArrowRight"===e.code&&(e.preventDefault(),W())},le=function(){O()},oe=function(e){e.preventDefault(),e.stopPropagation(),L=!1,A=!1,_=!0,E.startX=e.pageX,E.startY=e.pageY,r[l].slider.classList.add("parvus__slider--is-dragging"),r[l].slider.style.willChange="transform"},de=function(e){e.preventDefault(),_&&(E.endX=e.pageX,E.endY=e.pageY,he())},ue=function(e){e.stopPropagation(),_=!1,r[l].slider.classList.remove("parvus__slider--is-dragging"),r[l].slider.style.willChange="auto",(E.endX||E.endY)&&Z(),Q()},ce=function(e){e.stopPropagation(),L=!1,A=!1,_=!0,E.startX=e.touches[0].pageX,E.startY=e.touches[0].pageY,r[l].slider.classList.add("parvus__slider--is-dragging"),r[l].slider.style.willChange="transform"},pe=function(e){e.stopPropagation(),_&&(e.preventDefault(),E.endX=e.touches[0].pageX,E.endY=e.touches[0].pageY,he())},ge=function(e){e.stopPropagation(),_=!1,r[l].slider.classList.remove("parvus__slider--is-dragging"),r[l].slider.style.willChange="auto",(E.endX||E.endY)&&Z(),Q()},he=function(){const e=E.startX-E.endX,t=E.endY-E.startY,n=Math.abs(t);Math.abs(e)>0&&!A&&r[l].gallery.length>1?(r[l].slider.style.transform=`translate3d(${$-Math.round(e)}px, 0, 0)`,L=!0,A=!1):Math.abs(t)>0&&!L&&d.swipeClose&&(n<=96&&!S&&(p=1-n/100),u.classList.add("parvus--is-vertical-closing"),c.style.opacity=p,r[l].slider.style.transform=`translate3d(${$}px, ${Math.round(t)}px, 0)`,L=!1,A=!0)},me=function(){n.addEventListener("keydown",ae),n.addEventListener("resize",te),d.scrollClose&&n.addEventListener("wheel",le),n.addEventListener("popstate",O),u.addEventListener("click",ie),be()&&(u.addEventListener("touchstart",ce),u.addEventListener("touchmove",pe),u.addEventListener("touchend",ge)),u.addEventListener("mousedown",oe),u.addEventListener("mouseup",ue),u.addEventListener("mousemove",de)},ve=function(){n.removeEventListener("keydown",ae),n.removeEventListener("resize",te),d.scrollClose&&n.removeEventListener("wheel",le),n.removeEventListener("popstate",O),u.removeEventListener("click",ie),be()&&(u.removeEventListener("touchstart",ce),u.removeEventListener("touchmove",pe),u.removeEventListener("touchend",ge)),u.removeEventListener("mousedown",oe),u.removeEventListener("mouseup",ue),u.removeEventListener("mousemove",de)},fe=function(){return"false"===u.getAttribute("aria-hidden")},be=function(){return"ontouchstart"in window};return q(t),e.init=q,e.open=D,e.close=O,e.select=R,e.previous=j,e.next=W,e.currentIndex=function(){return o},e.add=Y,e.remove=k,e.destroy=function(){if(!u)return;fe()&&O(),u.remove();document.querySelectorAll(".parvus-trigger").forEach((e=>{k(e)}));const e=new CustomEvent("destroy");u.dispatchEvent(e)},e.isOpen=fe,e.on=function(e,t){u&&u.addEventListener(e,t)},e.off=function(e,t){u&&u.removeEventListener(e,t)},e}export{e as default};

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

* @author de Oostfreese
* @version 1.4.0
* @version 1.4.1
* @url https://github.com/deoostfreese/parvus

@@ -11,2 +11,3 @@ *

*/
(function (global, factory) {

@@ -213,3 +214,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :

if (GROUPS[newGroup].gallery.indexOf(el) === -1) {
if (!GROUPS[newGroup].gallery.includes(el)) {
GROUPS[newGroup].gallery.push(el);

@@ -254,3 +255,3 @@

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

@@ -381,3 +382,3 @@ } // TODO: Remove elements dynamically

if (GROUPS[activeGroup].gallery.indexOf(el) === -1) {
if (!GROUPS[activeGroup].gallery.includes(el)) {
throw new Error('Ups, I can\'t find the element.');

@@ -384,0 +385,0 @@ }

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

* @author de Oostfreese
* @version 1.4.0
* @version 1.4.1
* @url https://github.com/deoostfreese/parvus

@@ -11,2 +11,3 @@ *

*/
!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";return function e(t){const n=window,i=["button:not([disabled]):not([inert])",'[tabindex]:not([tabindex^="-"]):not([inert])'],s={gallery:[],slider:null,sliderElements:[]},r={};let a=null,o=null,l=0,d={},u=null,c=null,p=1,g=null,h=null,m=null,f=null,v=0,b=0,y=0,w=0,E={},L=!1,A=!1,_=!1,x=null,C=null,$=null,T=!1,B=null,S=!0;const M=window.matchMedia("(prefers-reduced-motion)"),I=function(){M.matches?(S=!0,B=d.reducedTransitionDuration):(S=!1,B=d.transitionDuration)};M.addEventListener("change",I);const q=function(e){d=function(e){return{selector:".lightbox",gallerySelector:null,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>',lang:"en",i18n:{en:{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"}},fileTypes:/\.(png|jpe?g|webp|avif|svg)(\?.*)?$/i,...e}}(e);if(document.querySelectorAll(d.selector).length)if(I(),u||F(),null!==d.gallerySelector){document.querySelectorAll(d.gallerySelector).forEach(((e,t)=>{const n=t;e.querySelectorAll(d.selector).forEach((e=>{e.setAttribute("data-group",`parvus-gallery-${n}`),Y(e)}))}));document.querySelectorAll(`${d.selector}:not(.parvus-trigger)`).forEach((e=>{Y(e)}))}else{document.querySelectorAll(d.selector).forEach((e=>{Y(e)}))}},X=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")},Y=function(e){if(!("A"===e.tagName&&e.hasAttribute("href")&&e.href.match(d.fileTypes)||"BUTTON"===e.tagName&&e.hasAttribute("data-target")&&e.getAttribute("data-target").match(d.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: ${d.fileTypes}.`);var t;if(a=X(e),Object.prototype.hasOwnProperty.call(r,a)||(r[a]=(t=s,JSON.parse(JSON.stringify(t)))),-1!==r[a].gallery.indexOf(e))throw new Error("Ups, element already added.");if(r[a].gallery.push(e),null!==e.querySelector("img")){const t=document.createElement("div");e.classList.add("parvus-zoom"),t.className="parvus-zoom__indicator",t.innerHTML=d.lightboxIndicatorIcon,e.appendChild(t)}e.classList.add("parvus-trigger"),e.addEventListener("click",ne),ve()&&a===o&&(N(e,r[a].gallery.indexOf(e)),U(r[a].gallery.indexOf(e)),ee(),V(),G())},k=function(e){if(ve()||!u||!e||!e.hasAttribute("data-group"))return;const t=X(e);if(-1===r[t].gallery.indexOf(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",ne),e.classList.remove("parvus-trigger")},F=function(){u=document.createElement("div"),u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-hidden","true"),u.setAttribute("tabindex","-1"),u.setAttribute("aria-label",d.i18n[d.lang].lightboxLabel),u.classList.add("parvus"),c=document.createElement("div"),c.classList.add("parvus__overlay"),c.style.opacity=0,u.appendChild(c),m=document.createElement("button"),m.className="parvus__btn parvus__btn--close",m.setAttribute("type","button"),m.setAttribute("aria-label",d.i18n[d.lang].closeButtonLabel),m.innerHTML=d.closeButtonIcon,u.appendChild(m),g=document.createElement("button"),g.className="parvus__btn parvus__btn--previous",g.setAttribute("type","button"),g.setAttribute("aria-label",d.i18n[d.lang].previousButtonLabel),g.innerHTML=d.previousButtonIcon,u.appendChild(g),h=document.createElement("button"),h.className="parvus__btn parvus__btn--next",h.setAttribute("type","button"),h.setAttribute("aria-label",d.i18n[d.lang].nextButtonLabel),h.innerHTML=d.nextButtonIcon,u.appendChild(h),f=document.createElement("div"),f.className="parvus__counter",u.appendChild(f),document.body.appendChild(u)},N=function(e,t){const n=document.createElement("div"),i=document.createElement("div");n.className="parvus__slide",n.style.position="absolute",n.style.left=100*t+"%",n.setAttribute("aria-hidden","true"),P(e,i),n.appendChild(i),r[o].sliderElements[t]=n,t===l&&r[o].slider.appendChild(n),t>l?r[o].sliderElements[l].after(n):r[o].sliderElements[l].before(n)},O=function(e){if(!u||!e||!e.classList.contains("parvus-trigger")||ve())return;if(o=X(e),-1===r[o].gallery.indexOf(e))throw new Error("Ups, I can't find the element.");l=r[o].gallery.indexOf(e),x=document.activeElement;const t=window.location.href;history.pushState({parvus:"close"},"Image",t),me();document.querySelectorAll('body > *:not([aria-hidden="true"])').forEach((e=>{e.setAttribute("aria-hidden","true"),e.classList.add("parvus-hidden")})),u.classList.add("parvus--is-opening"),u.setAttribute("aria-hidden","false"),r[o].slider=document.createElement("div"),r[o].slider.className="parvus__slider",r[o].slider.setAttribute("aria-hidden","true"),u.appendChild(r[o].slider),N(e,l),r[o].slider.setAttribute("aria-hidden","false"),K(),ee(),G(),re(),H(l),U(l),requestAnimationFrame((()=>{u.classList.remove("parvus--is-opening"),c.style.opacity=1,c.style.transition=`opacity ${B}ms ${d.transitionTimingFunction}`,c.style.willChange="opacity"})),c.addEventListener("transitionend",(()=>{z(l+1),z(l-1)})),r[o].slider.classList.add("parvus__slider--animate");const n=new CustomEvent("open",{detail:{source:e}});u.dispatchEvent(n)},D=function(){if(!ve())throw new Error("Ups, I'm already closed.");const e=r[o].sliderElements[l].querySelector("img"),t=e.getBoundingClientRect(),n=(d.backFocus?r[o].gallery[l]:x).getBoundingClientRect();fe(),Q(),null!==history.state&&"close"===history.state.parvus&&history.back();document.querySelectorAll(".parvus-hidden").forEach((e=>{e.removeAttribute("aria-hidden"),e.classList.remove("parvus-hidden")})),u.classList.add("parvus--is-closing"),requestAnimationFrame((()=>{v=n.width/t.width,b=n.height/t.height,y=n.left-t.left,w=n.top-t.top,e.style.transform=`translate(${y}px, ${w}px) scale(${v}, ${b})`,e.style.opacity=0,e.style.transition=`transform ${B}ms ${d.transitionTimingFunction}, opacity ${B}ms ${d.transitionTimingFunction} ${B/2}ms`,c.style.opacity=0,c.style.transition=`opacity ${B}ms ${d.transitionTimingFunction}`,c.style.willChange="auto"})),c.addEventListener("transitionend",(()=>{J(l),x=d.backFocus?r[o].gallery[l]:x,x.focus({preventScroll:!0}),u.setAttribute("aria-hidden","true"),u.classList.remove("parvus--is-closing"),u.classList.remove("parvus--is-vertical-closing"),r[o].slider.remove(),e.style.transform=""}),{once:!0});const i=new CustomEvent("close",{detail:{source:r[o].gallery[l]}});u.dispatchEvent(i)},z=function(e){void 0!==r[o].gallery[e]&&(N(r[o].gallery[e],e),U(e))},H=function(e){r[o].sliderElements[e].classList.add("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","false")},P=function(e,t){const n=document.createElement("img"),i=document.createElement("figure"),s=document.createElement("figcaption"),r=e.querySelector("img"),a=document.createElement("div");a.className="parvus__loader",a.setAttribute("role","progressbar"),a.setAttribute("aria-label",d.i18n[d.lang].lightboxLoadingIndicatorLabel),t.appendChild(a),n.onload=()=>{t.removeChild(a),n.setAttribute("width",n.naturalWidth),n.setAttribute("height",n.naturalHeight)},"A"===e.tagName?(n.setAttribute("src",e.href),n.alt=r?r.alt||"":e.getAttribute("data-alt")||""):(n.alt=e.getAttribute("data-alt")||"",n.setAttribute("src",e.getAttribute("data-target"))),e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&n.setAttribute("srcset",e.getAttribute("data-srcset")),n.style.opacity=0,i.appendChild(n),e.hasAttribute("data-caption")&&""!==e.getAttribute("data-caption")&&(s.innerHTML=e.getAttribute("data-caption"),i.appendChild(s)),t.appendChild(i)},U=function(e){const t=r[o].sliderElements[e].querySelector("img"),n=t.getBoundingClientRect(),i=r[o].gallery[e].getBoundingClientRect();u.classList.contains("parvus--is-opening")?(v=i.width/n.width,b=i.height/n.height,y=i.left-n.left,w=i.top-n.top,requestAnimationFrame((()=>{t.style.transform=`translate(${y}px, ${w}px) scale(${v}, ${b})`,t.style.transition="transform 0s, opacity 0s",requestAnimationFrame((()=>{t.style.transform="",t.style.opacity=1,t.style.transition=`transform ${B}ms ${d.transitionTimingFunction}, opacity ${B/2}ms ${d.transitionTimingFunction}`}))}))):t.style.opacity=1},R=function(e){const t=l;if(!ve())throw new Error("Ups, I'm closed.");if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===l)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}.`);J(t),H(e),U(e),e<t&&(l--,K(),ee(),V("left"),z(e-1)),e>t&&(l++,K(),ee(),V("right"),z(e+1)),G();const n=new CustomEvent("select",{detail:{source:r[o].gallery[l]}});u.dispatchEvent(n)},j=function(){l>0&&R(l-1)},W=function(){l<r[o].gallery.length-1&&R(l+1)},J=function(e){r[o].sliderElements[e].classList.remove("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","true")},K=function(){o=null!==o?o:a,C=-l*u.offsetWidth,r[o].slider.style.transform=`translate3d(${C}px, 0, 0)`,$=C},V=function(e){1===r[o].gallery.length?m.focus():0===l?h.focus():l===r[o].gallery.length-1||"left"===e?g.focus():h.focus()},G=function(){f.textContent=`${l+1}/${r[o].gallery.length}`},Q=function(){E={startX:0,endX:0,startY:0,endY:0}},Z=function(){const e=E.endX-E.startX,t=E.endY-E.startY,n=Math.abs(e),i=Math.abs(t);L&&e>0&&n>=d.threshold&&l>0?j():L&&e<0&&n>=d.threshold&&l!==r[o].gallery.length-1?W():A&&i>0?i>=d.threshold&&d.swipeClose?D():(c.style.opacity=1,u.classList.remove("parvus--is-vertical-closing"),K()):K()},ee=function(){(d.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?(g.setAttribute("aria-hidden","true"),g.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0):0===l?(g.setAttribute("aria-hidden","true"),g.disabled=!0,h.setAttribute("aria-hidden","false"),h.disabled=!1):l===r[o].gallery.length-1?(g.setAttribute("aria-hidden","false"),g.disabled=!1,h.setAttribute("aria-hidden","true"),h.disabled=!0):(g.setAttribute("aria-hidden","false"),g.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1),1===r[o].gallery.length?f.setAttribute("aria-hidden","true"):f.setAttribute("aria-hidden","false")},te=function(){T||(T=!0,n.requestAnimationFrame((()=>{K(),T=!1})))},ne=function(e){e.preventDefault(),O(this)},ie=function(e){e.target===g?j():e.target===h?W():(e.target===m||!A&&!L&&e.target.classList.contains("parvus__slide")&&d.docClose)&&D(),e.stopPropagation()},se=function(){return Array.prototype.slice.call(u.querySelectorAll(`${i.join(", ")}`)).filter((function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}))},re=function(){se()[0].focus()},ae=function(e){const t=se(),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(),D()):"ArrowLeft"===e.code?(e.preventDefault(),j()):"ArrowRight"===e.code&&(e.preventDefault(),W())},oe=function(){D()},le=function(e){e.preventDefault(),e.stopPropagation(),L=!1,A=!1,_=!0,E.startX=e.pageX,E.startY=e.pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},de=function(e){e.preventDefault(),_&&(E.endX=e.pageX,E.endY=e.pageY,he())},ue=function(e){e.stopPropagation(),_=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(E.endX||E.endY)&&Z(),Q()},ce=function(e){e.stopPropagation(),L=!1,A=!1,_=!0,E.startX=e.touches[0].pageX,E.startY=e.touches[0].pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},pe=function(e){e.stopPropagation(),_&&(e.preventDefault(),E.endX=e.touches[0].pageX,E.endY=e.touches[0].pageY,he())},ge=function(e){e.stopPropagation(),_=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(E.endX||E.endY)&&Z(),Q()},he=function(){const e=E.startX-E.endX,t=E.endY-E.startY,n=Math.abs(t);Math.abs(e)>0&&!A&&r[o].gallery.length>1?(r[o].slider.style.transform=`translate3d(${$-Math.round(e)}px, 0, 0)`,L=!0,A=!1):Math.abs(t)>0&&!L&&d.swipeClose&&(n<=96&&!S&&(p=1-n/100),u.classList.add("parvus--is-vertical-closing"),c.style.opacity=p,r[o].slider.style.transform=`translate3d(${$}px, ${Math.round(t)}px, 0)`,L=!1,A=!0)},me=function(){n.addEventListener("keydown",ae),n.addEventListener("resize",te),d.scrollClose&&n.addEventListener("wheel",oe),n.addEventListener("popstate",D),u.addEventListener("click",ie),be()&&(u.addEventListener("touchstart",ce),u.addEventListener("touchmove",pe),u.addEventListener("touchend",ge)),u.addEventListener("mousedown",le),u.addEventListener("mouseup",ue),u.addEventListener("mousemove",de)},fe=function(){n.removeEventListener("keydown",ae),n.removeEventListener("resize",te),d.scrollClose&&n.removeEventListener("wheel",oe),n.removeEventListener("popstate",D),u.removeEventListener("click",ie),be()&&(u.removeEventListener("touchstart",ce),u.removeEventListener("touchmove",pe),u.removeEventListener("touchend",ge)),u.removeEventListener("mousedown",le),u.removeEventListener("mouseup",ue),u.removeEventListener("mousemove",de)},ve=function(){return"false"===u.getAttribute("aria-hidden")},be=function(){return"ontouchstart"in window};return q(t),e.init=q,e.open=O,e.close=D,e.select=R,e.previous=j,e.next=W,e.currentIndex=function(){return l},e.add=Y,e.remove=k,e.destroy=function(){if(!u)return;ve()&&D(),u.remove();document.querySelectorAll(".parvus-trigger").forEach((e=>{k(e)}));const e=new CustomEvent("destroy");u.dispatchEvent(e)},e.isOpen=ve,e.on=function(e,t){u&&u.addEventListener(e,t)},e.off=function(e,t){u&&u.removeEventListener(e,t)},e}}));
!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";return function e(t){const n=window,i=["button:not([disabled]):not([inert])",'[tabindex]:not([tabindex^="-"]):not([inert])'],s={gallery:[],slider:null,sliderElements:[]},r={};let a=null,o=null,l=0,d={},u=null,c=null,p=1,g=null,h=null,m=null,f=null,v=0,b=0,y=0,w=0,E={},L=!1,A=!1,_=!1,x=null,C=null,$=null,T=!1,B=null,S=!0;const M=window.matchMedia("(prefers-reduced-motion)"),I=function(){M.matches?(S=!0,B=d.reducedTransitionDuration):(S=!1,B=d.transitionDuration)};M.addEventListener("change",I);const q=function(e){d=function(e){return{selector:".lightbox",gallerySelector:null,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>',lang:"en",i18n:{en:{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"}},fileTypes:/\.(png|jpe?g|webp|avif|svg)(\?.*)?$/i,...e}}(e);if(document.querySelectorAll(d.selector).length)if(I(),u||F(),null!==d.gallerySelector){document.querySelectorAll(d.gallerySelector).forEach(((e,t)=>{const n=t;e.querySelectorAll(d.selector).forEach((e=>{e.setAttribute("data-group",`parvus-gallery-${n}`),Y(e)}))}));document.querySelectorAll(`${d.selector}:not(.parvus-trigger)`).forEach((e=>{Y(e)}))}else{document.querySelectorAll(d.selector).forEach((e=>{Y(e)}))}},X=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")},Y=function(e){if(!("A"===e.tagName&&e.hasAttribute("href")&&e.href.match(d.fileTypes)||"BUTTON"===e.tagName&&e.hasAttribute("data-target")&&e.getAttribute("data-target").match(d.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: ${d.fileTypes}.`);var t;if(a=X(e),Object.prototype.hasOwnProperty.call(r,a)||(r[a]=(t=s,JSON.parse(JSON.stringify(t)))),r[a].gallery.includes(e))throw new Error("Ups, element already added.");if(r[a].gallery.push(e),null!==e.querySelector("img")){const t=document.createElement("div");e.classList.add("parvus-zoom"),t.className="parvus-zoom__indicator",t.innerHTML=d.lightboxIndicatorIcon,e.appendChild(t)}e.classList.add("parvus-trigger"),e.addEventListener("click",ne),ve()&&a===o&&(N(e,r[a].gallery.indexOf(e)),U(r[a].gallery.indexOf(e)),ee(),V(),G())},k=function(e){if(ve()||!u||!e||!e.hasAttribute("data-group"))return;const t=X(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",ne),e.classList.remove("parvus-trigger")},F=function(){u=document.createElement("div"),u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-hidden","true"),u.setAttribute("tabindex","-1"),u.setAttribute("aria-label",d.i18n[d.lang].lightboxLabel),u.classList.add("parvus"),c=document.createElement("div"),c.classList.add("parvus__overlay"),c.style.opacity=0,u.appendChild(c),m=document.createElement("button"),m.className="parvus__btn parvus__btn--close",m.setAttribute("type","button"),m.setAttribute("aria-label",d.i18n[d.lang].closeButtonLabel),m.innerHTML=d.closeButtonIcon,u.appendChild(m),g=document.createElement("button"),g.className="parvus__btn parvus__btn--previous",g.setAttribute("type","button"),g.setAttribute("aria-label",d.i18n[d.lang].previousButtonLabel),g.innerHTML=d.previousButtonIcon,u.appendChild(g),h=document.createElement("button"),h.className="parvus__btn parvus__btn--next",h.setAttribute("type","button"),h.setAttribute("aria-label",d.i18n[d.lang].nextButtonLabel),h.innerHTML=d.nextButtonIcon,u.appendChild(h),f=document.createElement("div"),f.className="parvus__counter",u.appendChild(f),document.body.appendChild(u)},N=function(e,t){const n=document.createElement("div"),i=document.createElement("div");n.className="parvus__slide",n.style.position="absolute",n.style.left=100*t+"%",n.setAttribute("aria-hidden","true"),P(e,i),n.appendChild(i),r[o].sliderElements[t]=n,t===l&&r[o].slider.appendChild(n),t>l?r[o].sliderElements[l].after(n):r[o].sliderElements[l].before(n)},D=function(e){if(!u||!e||!e.classList.contains("parvus-trigger")||ve())return;if(o=X(e),!r[o].gallery.includes(e))throw new Error("Ups, I can't find the element.");l=r[o].gallery.indexOf(e),x=document.activeElement;const t=window.location.href;history.pushState({parvus:"close"},"Image",t),me();document.querySelectorAll('body > *:not([aria-hidden="true"])').forEach((e=>{e.setAttribute("aria-hidden","true"),e.classList.add("parvus-hidden")})),u.classList.add("parvus--is-opening"),u.setAttribute("aria-hidden","false"),r[o].slider=document.createElement("div"),r[o].slider.className="parvus__slider",r[o].slider.setAttribute("aria-hidden","true"),u.appendChild(r[o].slider),N(e,l),r[o].slider.setAttribute("aria-hidden","false"),K(),ee(),G(),re(),H(l),U(l),requestAnimationFrame((()=>{u.classList.remove("parvus--is-opening"),c.style.opacity=1,c.style.transition=`opacity ${B}ms ${d.transitionTimingFunction}`,c.style.willChange="opacity"})),c.addEventListener("transitionend",(()=>{z(l+1),z(l-1)})),r[o].slider.classList.add("parvus__slider--animate");const n=new CustomEvent("open",{detail:{source:e}});u.dispatchEvent(n)},O=function(){if(!ve())throw new Error("Ups, I'm already closed.");const e=r[o].sliderElements[l].querySelector("img"),t=e.getBoundingClientRect(),n=(d.backFocus?r[o].gallery[l]:x).getBoundingClientRect();fe(),Q(),null!==history.state&&"close"===history.state.parvus&&history.back();document.querySelectorAll(".parvus-hidden").forEach((e=>{e.removeAttribute("aria-hidden"),e.classList.remove("parvus-hidden")})),u.classList.add("parvus--is-closing"),requestAnimationFrame((()=>{v=n.width/t.width,b=n.height/t.height,y=n.left-t.left,w=n.top-t.top,e.style.transform=`translate(${y}px, ${w}px) scale(${v}, ${b})`,e.style.opacity=0,e.style.transition=`transform ${B}ms ${d.transitionTimingFunction}, opacity ${B}ms ${d.transitionTimingFunction} ${B/2}ms`,c.style.opacity=0,c.style.transition=`opacity ${B}ms ${d.transitionTimingFunction}`,c.style.willChange="auto"})),c.addEventListener("transitionend",(()=>{J(l),x=d.backFocus?r[o].gallery[l]:x,x.focus({preventScroll:!0}),u.setAttribute("aria-hidden","true"),u.classList.remove("parvus--is-closing"),u.classList.remove("parvus--is-vertical-closing"),r[o].slider.remove(),e.style.transform=""}),{once:!0});const i=new CustomEvent("close",{detail:{source:r[o].gallery[l]}});u.dispatchEvent(i)},z=function(e){void 0!==r[o].gallery[e]&&(N(r[o].gallery[e],e),U(e))},H=function(e){r[o].sliderElements[e].classList.add("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","false")},P=function(e,t){const n=document.createElement("img"),i=document.createElement("figure"),s=document.createElement("figcaption"),r=e.querySelector("img"),a=document.createElement("div");a.className="parvus__loader",a.setAttribute("role","progressbar"),a.setAttribute("aria-label",d.i18n[d.lang].lightboxLoadingIndicatorLabel),t.appendChild(a),n.onload=()=>{t.removeChild(a),n.setAttribute("width",n.naturalWidth),n.setAttribute("height",n.naturalHeight)},"A"===e.tagName?(n.setAttribute("src",e.href),n.alt=r?r.alt||"":e.getAttribute("data-alt")||""):(n.alt=e.getAttribute("data-alt")||"",n.setAttribute("src",e.getAttribute("data-target"))),e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&n.setAttribute("srcset",e.getAttribute("data-srcset")),n.style.opacity=0,i.appendChild(n),e.hasAttribute("data-caption")&&""!==e.getAttribute("data-caption")&&(s.innerHTML=e.getAttribute("data-caption"),i.appendChild(s)),t.appendChild(i)},U=function(e){const t=r[o].sliderElements[e].querySelector("img"),n=t.getBoundingClientRect(),i=r[o].gallery[e].getBoundingClientRect();u.classList.contains("parvus--is-opening")?(v=i.width/n.width,b=i.height/n.height,y=i.left-n.left,w=i.top-n.top,requestAnimationFrame((()=>{t.style.transform=`translate(${y}px, ${w}px) scale(${v}, ${b})`,t.style.transition="transform 0s, opacity 0s",requestAnimationFrame((()=>{t.style.transform="",t.style.opacity=1,t.style.transition=`transform ${B}ms ${d.transitionTimingFunction}, opacity ${B/2}ms ${d.transitionTimingFunction}`}))}))):t.style.opacity=1},R=function(e){const t=l;if(!ve())throw new Error("Ups, I'm closed.");if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===l)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}.`);J(t),H(e),U(e),e<t&&(l--,K(),ee(),V("left"),z(e-1)),e>t&&(l++,K(),ee(),V("right"),z(e+1)),G();const n=new CustomEvent("select",{detail:{source:r[o].gallery[l]}});u.dispatchEvent(n)},j=function(){l>0&&R(l-1)},W=function(){l<r[o].gallery.length-1&&R(l+1)},J=function(e){r[o].sliderElements[e].classList.remove("parvus__slide--is-active"),r[o].sliderElements[e].setAttribute("aria-hidden","true")},K=function(){o=null!==o?o:a,C=-l*u.offsetWidth,r[o].slider.style.transform=`translate3d(${C}px, 0, 0)`,$=C},V=function(e){1===r[o].gallery.length?m.focus():0===l?h.focus():l===r[o].gallery.length-1||"left"===e?g.focus():h.focus()},G=function(){f.textContent=`${l+1}/${r[o].gallery.length}`},Q=function(){E={startX:0,endX:0,startY:0,endY:0}},Z=function(){const e=E.endX-E.startX,t=E.endY-E.startY,n=Math.abs(e),i=Math.abs(t);L&&e>0&&n>=d.threshold&&l>0?j():L&&e<0&&n>=d.threshold&&l!==r[o].gallery.length-1?W():A&&i>0?i>=d.threshold&&d.swipeClose?O():(c.style.opacity=1,u.classList.remove("parvus--is-vertical-closing"),K()):K()},ee=function(){(d.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?(g.setAttribute("aria-hidden","true"),g.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0):0===l?(g.setAttribute("aria-hidden","true"),g.disabled=!0,h.setAttribute("aria-hidden","false"),h.disabled=!1):l===r[o].gallery.length-1?(g.setAttribute("aria-hidden","false"),g.disabled=!1,h.setAttribute("aria-hidden","true"),h.disabled=!0):(g.setAttribute("aria-hidden","false"),g.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1),1===r[o].gallery.length?f.setAttribute("aria-hidden","true"):f.setAttribute("aria-hidden","false")},te=function(){T||(T=!0,n.requestAnimationFrame((()=>{K(),T=!1})))},ne=function(e){e.preventDefault(),D(this)},ie=function(e){e.target===g?j():e.target===h?W():(e.target===m||!A&&!L&&e.target.classList.contains("parvus__slide")&&d.docClose)&&O(),e.stopPropagation()},se=function(){return Array.prototype.slice.call(u.querySelectorAll(`${i.join(", ")}`)).filter((function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}))},re=function(){se()[0].focus()},ae=function(e){const t=se(),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(),O()):"ArrowLeft"===e.code?(e.preventDefault(),j()):"ArrowRight"===e.code&&(e.preventDefault(),W())},oe=function(){O()},le=function(e){e.preventDefault(),e.stopPropagation(),L=!1,A=!1,_=!0,E.startX=e.pageX,E.startY=e.pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},de=function(e){e.preventDefault(),_&&(E.endX=e.pageX,E.endY=e.pageY,he())},ue=function(e){e.stopPropagation(),_=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(E.endX||E.endY)&&Z(),Q()},ce=function(e){e.stopPropagation(),L=!1,A=!1,_=!0,E.startX=e.touches[0].pageX,E.startY=e.touches[0].pageY,r[o].slider.classList.add("parvus__slider--is-dragging"),r[o].slider.style.willChange="transform"},pe=function(e){e.stopPropagation(),_&&(e.preventDefault(),E.endX=e.touches[0].pageX,E.endY=e.touches[0].pageY,he())},ge=function(e){e.stopPropagation(),_=!1,r[o].slider.classList.remove("parvus__slider--is-dragging"),r[o].slider.style.willChange="auto",(E.endX||E.endY)&&Z(),Q()},he=function(){const e=E.startX-E.endX,t=E.endY-E.startY,n=Math.abs(t);Math.abs(e)>0&&!A&&r[o].gallery.length>1?(r[o].slider.style.transform=`translate3d(${$-Math.round(e)}px, 0, 0)`,L=!0,A=!1):Math.abs(t)>0&&!L&&d.swipeClose&&(n<=96&&!S&&(p=1-n/100),u.classList.add("parvus--is-vertical-closing"),c.style.opacity=p,r[o].slider.style.transform=`translate3d(${$}px, ${Math.round(t)}px, 0)`,L=!1,A=!0)},me=function(){n.addEventListener("keydown",ae),n.addEventListener("resize",te),d.scrollClose&&n.addEventListener("wheel",oe),n.addEventListener("popstate",O),u.addEventListener("click",ie),be()&&(u.addEventListener("touchstart",ce),u.addEventListener("touchmove",pe),u.addEventListener("touchend",ge)),u.addEventListener("mousedown",le),u.addEventListener("mouseup",ue),u.addEventListener("mousemove",de)},fe=function(){n.removeEventListener("keydown",ae),n.removeEventListener("resize",te),d.scrollClose&&n.removeEventListener("wheel",oe),n.removeEventListener("popstate",O),u.removeEventListener("click",ie),be()&&(u.removeEventListener("touchstart",ce),u.removeEventListener("touchmove",pe),u.removeEventListener("touchend",ge)),u.removeEventListener("mousedown",le),u.removeEventListener("mouseup",ue),u.removeEventListener("mousemove",de)},ve=function(){return"false"===u.getAttribute("aria-hidden")},be=function(){return"ontouchstart"in window};return q(t),e.init=q,e.open=D,e.close=O,e.select=R,e.previous=j,e.next=W,e.currentIndex=function(){return l},e.add=Y,e.remove=k,e.destroy=function(){if(!u)return;ve()&&O(),u.remove();document.querySelectorAll(".parvus-trigger").forEach((e=>{k(e)}));const e=new CustomEvent("destroy");u.dispatchEvent(e)},e.isOpen=ve,e.on=function(e,t){u&&u.addEventListener(e,t)},e.off=function(e,t){u&&u.removeEventListener(e,t)},e}}));
{
"name": "parvus",
"version": "1.4.0",
"version": "1.4.1",
"description": "An accessible, open-source image lightbox with no dependencies.",

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

"devDependencies": {
"@babel/core": "^7.14.0",
"@babel/preset-env": "^7.14.1",
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"core-js": "^3.12.1",
"node-sass": "^6.0.0",
"postcss": "^8.2.15",
"postcss-preset-env": "^6.7.0",
"rollup": "^2.47.0",
"rollup-plugin-license": "^2.3.0",
"rollup-plugin-postcss": "^4.0.0",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"core-js": "^3.17.3",
"node-sass": "^6.0.1",
"postcss": "^8.3.6",
"rollup": "^2.56.3",
"rollup-plugin-license": "^2.5.0",
"rollup-plugin-postcss": "^4.0.1",
"rollup-plugin-terser": "^7.0.2",

@@ -31,2 +30,9 @@ "standard": "^16.0.3",

],
"standard": {
"globals": [
"history",
"CustomEvent",
"requestAnimationFrame"
]
},
"scripts": {

@@ -39,3 +45,3 @@ "build": "npm run buildJs && npm run buildCss",

"buildWatchCss": "rollup -c -w --environment BUILDCSS",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "standard src/js/parvus.js"
},

@@ -42,0 +48,0 @@ "repository": {

# Parvus
An accessible, open-source image lightbox with no dependencies.
Parvus is an accessible, open-source image lightbox with no dependencies.
![Screenshot of parvus. It shows the first picture of a gallery.](https://rqrauhvmra.com/parvus/parvus.png)
![Screenshot of Parvus. It shows the first picture of a gallery.](https://rqrauhvmra.com/parvus/parvus.png)

@@ -55,3 +55,3 @@ [Open in CodePen](https://codepen.io/collection/DwLBpz)

Parvus is also available on npm.
You can install Parvus through npm or yarn like any other dependency:

@@ -116,3 +116,3 @@ ```

Instead of `data-group` you can also set the option `gallerySelector` to combine all images with the `selector` class within this selector into a group.
Instead of `data-group`, you can also set the option `gallerySelector` to combine all images with the `selector` class within this selector into a group.

@@ -119,0 +119,0 @@ ```html

@@ -10,13 +10,11 @@ import resolve from '@rollup/plugin-node-resolve'

const banner = [
'/**',
'\n * Parvus',
'\n *',
'\n * @author ', pkg.author,
'\n * @version ', pkg.version,
'\n * @url ', pkg.homepage,
'\n *',
'\n * ', pkg.license, ' license',
'\n */'].join('')
const bannerContent = `
Parvus
@author ${pkg.author}
@version ${pkg.version}
@url ${pkg.homepage}
${pkg.license} license`
let rollupBuilds

@@ -69,3 +67,3 @@

['@babel/preset-env', {
corejs: 3.6,
corejs: 3.15,
useBuiltIns: 'usage'

@@ -76,3 +74,5 @@ }]

license({
banner
banner: {
content: bannerContent
}
})

@@ -95,4 +95,3 @@ ],

{
file: './dist/css/parvus.css',
format: 'es'
file: './dist/css/parvus.css'
}

@@ -106,9 +105,8 @@ ],

postcss({
extract: true,
plugins: [
require('postcss-preset-env')
]
extract: true
}),
license({
banner
banner: {
content: bannerContent
}
})

@@ -124,4 +122,3 @@ ],

{
file: './dist/css/parvus.min.css',
format: 'es'
file: './dist/css/parvus.min.css'
}

@@ -136,9 +133,8 @@ ],

extract: true,
minimize: true,
plugins: [
require('postcss-preset-env')
]
minimize: true
}),
license({
banner
banner: {
content: bannerContent
}
})

@@ -145,0 +141,0 @@ ],

@@ -204,3 +204,3 @@ export default function Parvus (userOptions) {

// Check if element already exists
if (GROUPS[newGroup].gallery.indexOf(el) === -1) {
if (!GROUPS[newGroup].gallery.includes(el)) {
GROUPS[newGroup].gallery.push(el)

@@ -249,3 +249,3 @@

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

@@ -397,3 +397,3 @@ }

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

@@ -400,0 +400,0 @@ }

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