diff --git a/README.md b/README.md index e58ad8a..6fbefdd 100644 --- a/README.md +++ b/README.md @@ -1,216 +1,224 @@ -# Fancyapps UI - -Collection of task-oriented components that will make you more productive. Packed full of features that you and your clients will love. - -Full docs with examples: https://fancyapps.com/docs/ui/quick-start/. - -## Installation - -### NPM - -Use either `npm` or `yarn` as follows: - -```bash -npm install @fancyapps/ui -// or -yarn add @fancyapps/ui -``` - -Import one or more components: - -```jsx -import { Fancybox, Carousel, Panzoom } from "@fancyapps/ui"; -``` - -Import the appropriate CSS file, example: - -```jsx -import "@fancyapps/ui/dist/fancybox.css"; -``` - -### CDN - -A pre-bundled scripts that contain components are available on [CDN](https://www.jsdelivr.com/package/npm/@fancyapps/ui?path=dist). - -> **_NOTE:_** Because Fancybox is build on top of both Carousel and Panzoom components, you only have to include `fancybox.umd.js` and all 3 components will be available through the `window` object. - -```html - -``` - -Or use ES6 import: - -```html - -``` - -Remember to include the appropriate CSS file, example: - -```html - -``` - -## Usage - -### Fancybox - -There are two ways to use Fancybox. - -#### Declarative - -Add a `data-fancybox` attribute to any element to enable Fancybox. Galleries are created by adding the same attribute `data-fancybox` value to multiple elements. Use `data-src` or `href` attribute to specify the source of the content. - -```jsx - - Image - -``` - -```jsx - - Video - -``` - -```jsx - - Iframe - -``` - -```jsx - - -
-``` - -#### Programmatic - -```js -// Image gallery -var gallery = [ - { - src: "https://lipsum.app/id/2/800x600", - thumb: "https://lipsum.app/id/2/80x80", - caption: "First image", - }, - { - src: "https://lipsum.app/id/3/800x600", - thumb: "https://lipsum.app/id/3/80x80", - caption: "Second image", - }, - { - src: "https://lipsum.app/id/4/800x600", - thumb: "https://lipsum.app/id/4/80x80", - caption: "Third image", - }, -]; - -Fancybox.show(gallery, { - // Your options go here -}); - -// HTML element -Fancybox.show([{ src: "#dialog-content", type: "inline" }]); - -// A copy of HTML element -Fancybox.show([{ src: "#dialog-content", type: "clone" }]); - -// Any HTML content -Fancybox.show([{ src: "Lorem ipsum dolor sit amet.
", type: "html" }]); -``` - -### Carousel - -Add HTML markup - -```html -Lorem ipsum dolor sit amet.
", type: "html" }]); +``` + +### Carousel + +Add HTML markup + +```html +{{ERROR}}
"),this.setContent(t,i,{suffix:"error"})}showLoading(t){t.state="loading",t.$el.classList.add("is-loading");let e=t.$el.querySelector(".fancybox__spinner");e||(e=document.createElement("div"),e.classList.add("fancybox__spinner"),e.innerHTML=this.option("template.spinner"),e.addEventListener("click",(()=>{this.Carousel.Panzoom.velocity||this.close()})),t.$el.insertBefore(e,t.$el.firstChild))}hideLoading(t){const e=t.$el.querySelector(".fancybox__spinner");e&&e.remove(),t.$el.classList.remove("is-loading")}next(){const t=this.Carousel;t&&t.pages.length>1&&t.slideNext()}prev(){const t=this.Carousel;t&&t.pages.length>1&&t.slidePrev()}jumpTo(...t){this.Carousel&&this.Carousel.slideTo(...t)}close(t){if(t&&t.preventDefault(),["closing","customClosing","destroy"].indexOf(this.state)>-1)return;if(!1===this.trigger("shouldClose",t))return;if(this.state="closing",this.Carousel.Panzoom.destroy(),this.detachEvents(),this.trigger("closing",t),"destroy"===this.state)return;this.$container.setAttribute("aria-hidden","true"),this.$container.classList.add("is-closing");const e=this.getSlide();if(this.Carousel.slides.forEach((t=>{t.$content&&t.index!==e.index&&t.$content.remove()})),"closing"===this.state){const t=void 0===e.hideClass?this.option("hideClass"):e.hideClass;this.animateCSS(e.$content,t,(()=>{this.destroy()}))}}destroy(){this.state="destroy",this.trigger("destroy");const t=this.option("placeFocusBack")?this.getSlide().$trigger:null;if(this.Carousel.destroy(),this.detachPlugins(),this.Carousel=null,this.options={},this.events={},this.$container.remove(),this.$container=this.$backdrop=this.$carousel=null,t)if(L)t.focus({preventScroll:!0});else{const e=document.body.scrollTop;t.focus(),document.body.scrollTop=e}const e=T.getInstance();e?e.focus():(document.documentElement.classList.remove("with-fancybox"),document.body.classList.remove("is-using-mouse"),this.revealScrollbar())}static show(t,e={}){return e.items=t,new T(e)}static fromEvent(t,e={}){if(t.defaultPrevented)return;if(t.button&&0!==t.button)return;if(t.ctrlKey||t.metaKey||t.shiftKey)return;let i,s,n,o=!1,a=t.target;if((a.matches("[data-fancybox-trigger]")||(a=a.closest("[data-fancybox-trigger]")))&&(n=a&&a.dataset&&a.dataset.fancyboxTrigger),n){const t=document.querySelectorAll(`[data-fancybox="${n}"]`),e=parseInt(a.dataset.fancyboxIndex,10)||0;a=t.length?t[e]:a}a||(a=t.target),Array.from(T.openers.keys()).reverse().some((e=>{if(i=a,i.matches(e)||(i=i.closest(e)))return t.preventDefault(),s=e,!0})),s&&(e.target=i,i.origTarget=t.target,o=T.fromOpener(s,e));const r=T.getInstance();return r&&"ready"===r.state&&t.detail&&document.body.classList.add("is-using-mouse"),o}static fromOpener(t,i={}){let s=[],n=i.startIndex||0,o=(i=e({},i,T.openers.get(t))).groupAttr;void 0===o&&(o="data-fancybox");let a=i.target;if(o){if(a&&t&&t===`[${o}]`){const e=a.getAttribute(`${o}`);t=!(!e||!e.length||"true"===e)&&`[${o}='${e}']`}}else t=!1;if(t&&(s=[].slice.call(document.querySelectorAll(t))),!s.length&&a&&(s=[a]),!s.length)return!1;const r=T.getInstance();return!(r&&s.indexOf(r.options.$trigger)>-1)&&(n=a?s.indexOf(a):n,s=s.map((function(t){const e=["false","0","no","null"],i=["true","1","yes"],s=Object.assign({},t.dataset);for(let[t,n]of Object.entries(s))if("string"==typeof n||n instanceof String)if(e.indexOf(n)>-1)s[t]=!1;else if(i.indexOf(s[t])>-1)s[t]=!0;else try{s[t]=JSON.parse(n)}catch(e){s[t]=n}return delete s.fancybox,delete s.type,t instanceof Element&&(s.$trigger=t),s})),new T(e({},i,{items:s,startIndex:n,$trigger:a})))}static assign(t,e={}){if(f){if(!T.openers.size){document.body.addEventListener("click",T.fromEvent,!1);for(const[t,e]of Object.entries(T.Plugins||{}))e.Fancybox=this,"function"==typeof e.create&&e.create()}T.openers.set(t,e)}}static trash(t){T.openers.delete(t),T.openers.size||T.destroy()}static destroy(){T.openers=new Map,document.body.removeEventListener("click",T.fromEvent,!1)}static getInstance(t){let e=[];e=t?[document.getElementById(`fancybox-${t}`)]:Array.from(document.querySelectorAll(".fancybox__container")).reverse();for(const t of e){const e=t&&t.Fancybox;if(e&&"closing"!==e.state&&"customClosing"!==e.state)return e}return null}static close(t=!0){let e=null;for(;e=T.getInstance();)if(e.close(),!t)return}}T.version="4.0.0-alpha.1",T.defaults={hideScrollbar:!0,items:[],startIndex:0,preload:1,infinite:!0,showClass:"fancybox-zoomInUp",hideClass:"fancybox-fadeOut",animated:!0,keyboard:{Escape:"close",Delete:"close",Backspace:"close",PageUp:"next",PageDown:"prev",ArrowUp:"next",ArrowDown:"prev",ArrowRight:"next",ArrowLeft:"prev"},template:{closeButton:'',spinner:'',main:null},parentEl:null,mainClass:null,autoFocus:!0,trapFocus:!0,placeFocusBack:!0,click:"close",closeButton:"inside",dragToClose:!0,l10n:{CLOSE:"Close",NEXT:"Next",PREV:"Previous",MODAL:"You can close this modal content with the ESC key",ERROR:"Something Went Wrong, Please Try Again Later",IMAGE_ERROR:"Image Not Found",ELEMENT_NOT_FOUND:"HTML Element Not Found",AJAX_NOT_FOUND:"Error Loading AJAX : Not Found",AJAX_FORBIDDEN:"Error Loading AJAX : Forbidden",IFRAME_ERROR:"Error Loading Page"}},T.openers=new Map,T.Plugins=S,T.isMobile=()=>!!navigator&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),T.assign("[data-fancybox]");export{m as Carousel,T as Fancybox,h as Panzoom}; +const t=t=>"object"==typeof t&&null!==t&&t.constructor===Object&&"[object Object]"===Object.prototype.toString.call(t),e=(...i)=>{let s=!1;"boolean"==typeof i[0]&&(s=i.shift());let n=i[0];if(!n||"object"!=typeof n)throw new Error("extendee must be an object");const o=i.slice(1),a=o.length;for(let i=0;i(t=parseFloat(t)||0,Math.round((t+Number.EPSILON)*e)/e),s="undefined"!=typeof window&&window.ResizeObserver||class{constructor(t){this.observables=[],this.boundCheck=this.check.bind(this),this.boundCheck(),this.callback=t}observe(t){if(this.observables.some((e=>e.el===t)))return;const e={el:t,size:{height:t.clientHeight,width:t.clientWidth}};this.observables.push(e)}unobserve(t){this.observables=this.observables.filter((e=>e.el!==t))}disconnect(){this.observables=[]}check(){const t=this.observables.filter((t=>{const e=t.el.clientHeight,i=t.el.clientWidth;if(t.size.height!==e||t.size.width!==i)return t.size.height=e,t.size.width=i,!0})).map((t=>t.el));t.length>0&&this.callback(t),window.requestAnimationFrame(this.boundCheck)}},n=function(t){return!(!t||t.classList.contains("carousel__track")||t===document.body)&&(function(t){const e=window.getComputedStyle(t)["overflow-y"],i=window.getComputedStyle(t)["overflow-x"],s=("scroll"===e||"auto"===e)&&Math.abs(t.scrollHeight-t.clientHeight)>1,n=("scroll"===i||"auto"===i)&&Math.abs(t.scrollWidth-t.clientWidth)>1;return s||n}(t)?t:n(t.parentNode))},o=t=>{let e=0;return t&&(e=t instanceof SVGElement?Math.min(t.getClientRects()[0].width,t.width.baseVal.value):Math.max(t.offsetWidth,t.scrollWidth)),e},a=t=>{let e=0;return t&&(e=t instanceof SVGElement?Math.min(t.getClientRects()[0].height,t.height.baseVal.value):Math.max(t.offsetHeight,t.scrollHeight)),e};class r{constructor(t={}){this.options=e(!0,{},t),this.plugins=[],this.events={};for(const t of["on","once"])for(const e of Object.entries(this.options[t]||{}))this[t](...e)}option(t,e){t=String(t);let i=(s=t,n=this.options,s.split(".").reduce((function(t,e){return t[e]}),n));var s,n;return"function"==typeof i&&(i=i.call(this,t)),void 0===i?e:i}localize(t,e=[]){return String(t).replace(/\{\{(\w+).?(\w+)?\}\}/g,((t,i,s)=>{let n=!1;if(n=s?this.option(`${i[0]+i.toLowerCase().substring(1)}.l10n.${s}`):this.option(`l10n.${i}`),!n)return i;for(let t=0;t{{ERROR}}
"),this.setContent(t,i,{suffix:"error"})}showLoading(t){t.state="loading",t.$el.classList.add("is-loading");let e=t.$el.querySelector(".fancybox__spinner");e||(e=document.createElement("div"),e.classList.add("fancybox__spinner"),e.innerHTML=this.option("template.spinner"),e.addEventListener("click",(()=>{this.Carousel.Panzoom.velocity||this.close()})),t.$el.insertBefore(e,t.$el.firstChild))}hideLoading(t){const e=t.$el.querySelector(".fancybox__spinner");e&&e.remove(),t.$el.classList.remove("is-loading")}next(){const t=this.Carousel;t&&t.pages.length>1&&t.slideNext()}prev(){const t=this.Carousel;t&&t.pages.length>1&&t.slidePrev()}jumpTo(...t){this.Carousel&&this.Carousel.slideTo(...t)}close(t){if(t&&t.preventDefault(),["closing","customClosing","destroy"].indexOf(this.state)>-1)return;if(!1===this.trigger("shouldClose",t))return;if(this.state="closing",this.Carousel.Panzoom.destroy(),this.detachEvents(),this.trigger("closing",t),"destroy"===this.state)return;this.$container.setAttribute("aria-hidden","true"),this.$container.classList.add("is-closing");const e=this.getSlide();if(this.Carousel.slides.forEach((t=>{t.$content&&t.index!==e.index&&t.$content.remove()})),"closing"===this.state){const t=void 0===e.hideClass?this.option("hideClass"):e.hideClass;this.animateCSS(e.$content,t,(()=>{this.destroy()}))}}destroy(){this.state="destroy",this.trigger("destroy");const t=this.option("placeFocusBack")?this.getSlide().$trigger:null;if(this.Carousel.destroy(),this.detachPlugins(),this.Carousel=null,this.options={},this.events={},this.$container.remove(),this.$container=this.$backdrop=this.$carousel=null,t)if(L)t.focus({preventScroll:!0});else{const e=document.body.scrollTop;t.focus(),document.body.scrollTop=e}const e=T.getInstance();e?e.focus():(document.documentElement.classList.remove("with-fancybox"),document.body.classList.remove("is-using-mouse"),this.revealScrollbar())}static show(t,e={}){return new T(t,e)}static fromEvent(t,e={}){if(t.defaultPrevented)return;if(t.button&&0!==t.button)return;if(t.ctrlKey||t.metaKey||t.shiftKey)return;let i,s,n,o=!1,a=t.target;if((a.matches("[data-fancybox-trigger]")||(a=a.closest("[data-fancybox-trigger]")))&&(n=a&&a.dataset&&a.dataset.fancyboxTrigger),n){const t=document.querySelectorAll(`[data-fancybox="${n}"]`),e=parseInt(a.dataset.fancyboxIndex,10)||0;a=t.length?t[e]:a}a||(a=t.target),Array.from(T.openers.keys()).reverse().some((e=>{if(i=a,i.matches(e)||(i=i.closest(e)))return t.preventDefault(),s=e,!0})),s&&(e.target=i,i.origTarget=t.target,o=T.fromOpener(s,e));const r=T.getInstance();return r&&"ready"===r.state&&t.detail&&document.body.classList.add("is-using-mouse"),o}static fromOpener(t,i={}){let s=[],n=i.startIndex||0,o=(i=e({},i,T.openers.get(t))).groupAttr;void 0===o&&(o="data-fancybox");let a=i.target;if(o){if(a&&t&&t===`[${o}]`){const e=a.getAttribute(`${o}`);t=!(!e||!e.length||"true"===e)&&`[${o}='${e}']`}}else t=!1;if(t&&(s=[].slice.call(document.querySelectorAll(t))),!s.length&&a&&(s=[a]),!s.length)return!1;const r=T.getInstance();return!(r&&s.indexOf(r.options.$trigger)>-1)&&(n=a?s.indexOf(a):n,s=s.map((function(t){const e=["false","0","no","null"],i=["true","1","yes"],s=Object.assign({},t.dataset);for(let[t,n]of Object.entries(s))if("string"==typeof n||n instanceof String)if(e.indexOf(n)>-1)s[t]=!1;else if(i.indexOf(s[t])>-1)s[t]=!0;else try{s[t]=JSON.parse(n)}catch(e){s[t]=n}return delete s.fancybox,delete s.type,t instanceof Element&&(s.$trigger=t),s})),new T(s,e({},i,{startIndex:n,$trigger:a})))}static bind(t,e={}){if(f){if(!T.openers.size){document.body.addEventListener("click",T.fromEvent,!1);for(const[t,e]of Object.entries(T.Plugins||{}))e.Fancybox=this,"function"==typeof e.create&&e.create()}T.openers.set(t,e)}}static unbind(t){T.openers.delete(t),T.openers.size||T.destroy()}static destroy(){let t;for(;t=T.getInstance();)t.destroy();T.openers=new Map,document.body.removeEventListener("click",T.fromEvent,!1)}static getInstance(t){let e=[];e=t?[document.getElementById(`fancybox-${t}`)]:Array.from(document.querySelectorAll(".fancybox__container")).reverse();for(const t of e){const e=t&&t.Fancybox;if(e&&"closing"!==e.state&&"customClosing"!==e.state)return e}return null}static close(t=!0){let e=null;for(;e=T.getInstance();)if(e.close(),!t)return}}T.version="4.0.0-alpha.1",T.defaults={startIndex:0,preload:1,infinite:!0,showClass:"fancybox-zoomInUp",hideClass:"fancybox-fadeOut",animated:!0,hideScrollbar:!0,parentEl:null,mainClass:null,autoFocus:!0,trapFocus:!0,placeFocusBack:!0,click:"close",closeButton:"inside",dragToClose:!0,keyboard:{Escape:"close",Delete:"close",Backspace:"close",PageUp:"next",PageDown:"prev",ArrowUp:"next",ArrowDown:"prev",ArrowRight:"next",ArrowLeft:"prev"},template:{closeButton:'',spinner:'',main:null},l10n:{CLOSE:"Close",NEXT:"Next",PREV:"Previous",MODAL:"You can close this modal content with the ESC key",ERROR:"Something Went Wrong, Please Try Again Later",IMAGE_ERROR:"Image Not Found",ELEMENT_NOT_FOUND:"HTML Element Not Found",AJAX_NOT_FOUND:"Error Loading AJAX : Not Found",AJAX_FORBIDDEN:"Error Loading AJAX : Forbidden",IFRAME_ERROR:"Error Loading Page"}},T.openers=new Map,T.Plugins=S,T.isMobile=()=>!!navigator&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),T.bind("[data-fancybox]");export{m as Carousel,T as Fancybox,h as Panzoom}; diff --git a/dist/fancybox.umd.js b/dist/fancybox.umd.js index eb3850f..41f4c55 100644 --- a/dist/fancybox.umd.js +++ b/dist/fancybox.umd.js @@ -1,2 +1,2 @@ // @fancyapps/ui/Fancybox v4.0.0-alpha.1 -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var i=0;i{{ERROR}}
"),this.setContent(t,i,{suffix:"error"})}},{key:"showLoading",value:function(t){var e=this;t.state="loading",t.$el.classList.add("is-loading");var i=t.$el.querySelector(".fancybox__spinner");i||((i=document.createElement("div")).classList.add("fancybox__spinner"),i.innerHTML=this.option("template.spinner"),i.addEventListener("click",(function(){e.Carousel.Panzoom.velocity||e.close()})),t.$el.insertBefore(i,t.$el.firstChild))}},{key:"hideLoading",value:function(t){var e=t.$el.querySelector(".fancybox__spinner");e&&e.remove(),t.$el.classList.remove("is-loading")}},{key:"next",value:function(){var t=this.Carousel;t&&t.pages.length>1&&t.slideNext()}},{key:"prev",value:function(){var t=this.Carousel;t&&t.pages.length>1&&t.slidePrev()}},{key:"jumpTo",value:function(){var t;this.Carousel&&(t=this.Carousel).slideTo.apply(t,arguments)}},{key:"close",value:function(t){var e=this;if(t&&t.preventDefault(),!(["closing","customClosing","destroy"].indexOf(this.state)>-1)&&!1!==this.trigger("shouldClose",t)&&(this.state="closing",this.Carousel.Panzoom.destroy(),this.detachEvents(),this.trigger("closing",t),"destroy"!==this.state)){this.$container.setAttribute("aria-hidden","true"),this.$container.classList.add("is-closing");var i=this.getSlide();if(this.Carousel.slides.forEach((function(t){t.$content&&t.index!==i.index&&t.$content.remove()})),"closing"===this.state){var n=void 0===i.hideClass?this.option("hideClass"):i.hideClass;this.animateCSS(i.$content,n,(function(){e.destroy()}))}}}},{key:"destroy",value:function(){this.state="destroy",this.trigger("destroy");var t=this.option("placeFocusBack")?this.getSlide().$trigger:null;if(this.Carousel.destroy(),this.detachPlugins(),this.Carousel=null,this.options={},this.events={},this.$container.remove(),this.$container=this.$backdrop=this.$carousel=null,t)if(H)t.focus({preventScroll:!0});else{var e=document.body.scrollTop;t.focus(),document.body.scrollTop=e}var i=n.getInstance();i?i.focus():(document.documentElement.classList.remove("with-fancybox"),document.body.classList.remove("is-using-mouse"),this.revealScrollbar())}}],[{key:"show",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.items=t,new n(e)}},{key:"fromEvent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t.defaultPrevented&&!(t.button&&0!==t.button||t.ctrlKey||t.metaKey||t.shiftKey)){var i,o,s,a=!1,r=t.target;if((r.matches("[data-fancybox-trigger]")||(r=r.closest("[data-fancybox-trigger]")))&&(s=r&&r.dataset&&r.dataset.fancyboxTrigger),s){var l=document.querySelectorAll('[data-fancybox="'.concat(s,'"]')),c=parseInt(r.dataset.fancyboxIndex,10)||0;r=l.length?l[c]:r}r||(r=t.target),Array.from(n.openers.keys()).reverse().some((function(e){if((i=r).matches(e)||(i=i.closest(e)))return t.preventDefault(),o=e,!0})),o&&(e.target=i,i.origTarget=t.target,a=n.fromOpener(o,e));var h=n.getInstance();return h&&"ready"===h.state&&t.detail&&document.body.classList.add("is-using-mouse"),a}}},{key:"fromOpener",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=function(t){for(var e=["false","0","no","null"],i=["true","1","yes"],n=Object.assign({},t.dataset),o=0,s=Object.entries(n);o{{ERROR}}
"),this.setContent(t,i,{suffix:"error"})}},{key:"showLoading",value:function(t){var e=this;t.state="loading",t.$el.classList.add("is-loading");var i=t.$el.querySelector(".fancybox__spinner");i||((i=document.createElement("div")).classList.add("fancybox__spinner"),i.innerHTML=this.option("template.spinner"),i.addEventListener("click",(function(){e.Carousel.Panzoom.velocity||e.close()})),t.$el.insertBefore(i,t.$el.firstChild))}},{key:"hideLoading",value:function(t){var e=t.$el.querySelector(".fancybox__spinner");e&&e.remove(),t.$el.classList.remove("is-loading")}},{key:"next",value:function(){var t=this.Carousel;t&&t.pages.length>1&&t.slideNext()}},{key:"prev",value:function(){var t=this.Carousel;t&&t.pages.length>1&&t.slidePrev()}},{key:"jumpTo",value:function(){var t;this.Carousel&&(t=this.Carousel).slideTo.apply(t,arguments)}},{key:"close",value:function(t){var e=this;if(t&&t.preventDefault(),!(["closing","customClosing","destroy"].indexOf(this.state)>-1)&&!1!==this.trigger("shouldClose",t)&&(this.state="closing",this.Carousel.Panzoom.destroy(),this.detachEvents(),this.trigger("closing",t),"destroy"!==this.state)){this.$container.setAttribute("aria-hidden","true"),this.$container.classList.add("is-closing");var i=this.getSlide();if(this.Carousel.slides.forEach((function(t){t.$content&&t.index!==i.index&&t.$content.remove()})),"closing"===this.state){var n=void 0===i.hideClass?this.option("hideClass"):i.hideClass;this.animateCSS(i.$content,n,(function(){e.destroy()}))}}}},{key:"destroy",value:function(){this.state="destroy",this.trigger("destroy");var t=this.option("placeFocusBack")?this.getSlide().$trigger:null;if(this.Carousel.destroy(),this.detachPlugins(),this.Carousel=null,this.options={},this.events={},this.$container.remove(),this.$container=this.$backdrop=this.$carousel=null,t)if(H)t.focus({preventScroll:!0});else{var e=document.body.scrollTop;t.focus(),document.body.scrollTop=e}var i=n.getInstance();i?i.focus():(document.documentElement.classList.remove("with-fancybox"),document.body.classList.remove("is-using-mouse"),this.revealScrollbar())}}],[{key:"show",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new n(t,e)}},{key:"fromEvent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t.defaultPrevented&&!(t.button&&0!==t.button||t.ctrlKey||t.metaKey||t.shiftKey)){var i,o,s,a=!1,r=t.target;if((r.matches("[data-fancybox-trigger]")||(r=r.closest("[data-fancybox-trigger]")))&&(s=r&&r.dataset&&r.dataset.fancyboxTrigger),s){var l=document.querySelectorAll('[data-fancybox="'.concat(s,'"]')),c=parseInt(r.dataset.fancyboxIndex,10)||0;r=l.length?l[c]:r}r||(r=t.target),Array.from(n.openers.keys()).reverse().some((function(e){if((i=r).matches(e)||(i=i.closest(e)))return t.preventDefault(),o=e,!0})),o&&(e.target=i,i.origTarget=t.target,a=n.fromOpener(o,e));var h=n.getInstance();return h&&"ready"===h.state&&t.detail&&document.body.classList.add("is-using-mouse"),a}}},{key:"fromOpener",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=function(t){for(var e=["false","0","no","null"],i=["true","1","yes"],n=Object.assign({},t.dataset),o=0,s=Object.entries(n);o