diff --git a/dist/formats/cjs/caroucssel.js b/dist/formats/cjs/caroucssel.js
index ea5a013b..b4531ec2 100644
--- a/dist/formats/cjs/caroucssel.js
+++ b/dist/formats/cjs/caroucssel.js
@@ -13,6 +13,10 @@ function __rest(s, e) {
}
return t;
}
+typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
+ var e = new Error(message);
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
+};
const __CACHE = new WeakMap();
function fromCache(ref, key, factory) {
@@ -798,7 +802,7 @@ class Carousel {
}
}
-const version = '1.1.3';
+const version = '1.1.4';
exports.Buttons = Buttons;
exports.Carousel = Carousel;
diff --git a/dist/formats/cjs/caroucssel.min.js b/dist/formats/cjs/caroucssel.min.js
index 1cf39439..4d38cea5 100644
--- a/dist/formats/cjs/caroucssel.min.js
+++ b/dist/formats/cjs/caroucssel.min.js
@@ -1 +1 @@
-"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=new WeakMap;function e(e,s,n){const i=t.get(e)||new Map;if(i.has(s))return i.get(s);if(!n)return;const r=n();return i.set(s,r),t.set(e,i),r}function s(e,s,n){const i=t.get(e)||new Map;i.set(s,n),t.set(e,i)}function n(e,s){const n=t.get(e);n&&n.has(s)&&n.delete(s)}function i(e){t.delete(e)}function r(t,e){const s=document.createElement("div");s.innerHTML=t(e);const n=s.firstElementChild;return n||null}const o={template:({className:t,controls:e,label:s,title:n})=>`\n\t\t\n\t`,className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};function l(t){return t instanceof MouseEvent?t.clientX:0}const a={indicator:!1};var h,d;exports.UpdateType=void 0,(h=exports.UpdateType||(exports.UpdateType={})).SCROLL="scroll",h.RESIZE="resize",h.FORCED="forced",h.FEATURE="feature",exports.ScrollBehavior=void 0,(d=exports.ScrollBehavior||(exports.ScrollBehavior={})).AUTO="auto",d.SMOOTH="smooth";const c={template:({className:t,controls:e,pages:s,label:n,title:i})=>`\n\t\t
\n\t\t\t${s.map(((t,r)=>{const o={index:r,page:t,pages:s},l=n(o),a=i(o);return`- \n\t\t\t\t\t\n\t\t\t\t
`})).join("")}\n\t\t
\n\t`,className:"pagination",label:({index:t})=>`${t+1}`,title:({index:t})=>`Go to ${t+1}. page`};class u{constructor(){window.addEventListener("resize",(()=>{n(this,"dims")}))}get dimensions(){return e(this,"dims",(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const s=t.offsetHeight;e.style.overflow="scroll";let n=t.offsetHeight;n=s===n?e.clientHeight:n;const i=s-n;return document.body.removeChild(e),{height:i}}))}}let p;const g={enabled:!0,className:"caroucssel-mask",tagName:"div"};class m{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},g),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=e(this,"mask"))&&void 0!==t?t:null}init(t){s(this,"prxy",t),p=null!=p?p:new u,this._render()}destroy(){this._remove(),i(this)}update(t){switch(t.type){case exports.UpdateType.RESIZE:case exports.UpdateType.FORCED:n(this,"hght"),this._render();break;default:this._render()}}_render(){const{enabled:t,className:n,tagName:i}=e(this,"conf");if(!t)return;const r=e(this,"prxy").el;let{height:o}=p.dimensions;r.scrollWidth<=r.clientWidth&&(o=0),e(this,"mask",(()=>{var t;const e=document.createElement(i);return e.className=n,e.style.overflow="hidden",e.style.height="100%",null===(t=r.parentNode)||void 0===t||t.insertBefore(e,r),e.appendChild(r),e}));o!==e(this,"hght")&&(s(this,"hght",o),r.style.height=`calc(100% + ${o}px)`,r.style.marginBottom=-1*o+"px")}_remove(){var t,s;const{el:n}=e(this,"prxy"),i=e(this,"mask");null===(t=null==i?void 0:i.parentNode)||void 0===t||t.insertBefore(n,i),null===(s=null==i?void 0:i.parentNode)||void 0===s||s.removeChild(i),n.removeAttribute("style")}}function v(t){return e(t,"inst")}class f{constructor(t,e){s(this,"inst",t),s(this,"feat",e)}get id(){return v(this).id}get el(){return v(this).el}get mask(){return v(this).mask}get index(){return v(this).index}set index(t){v(this).index=t}get items(){return v(this).items}get pages(){return v(this).pages}get pageIndex(){return v(this).pageIndex}update(t){var s;v(this).update(),(s=this,e(s,"feat")).forEach((e=>{e!==t&&e.update({type:exports.UpdateType.FEATURE})}))}}function x(t,e){let s=null;return(...n)=>{null!==s&&clearTimeout(s),s=setTimeout((()=>t(...n)),e)}}const y=/^caroucssel-[0-9]*$/,b=/^(link|meta|noscript|script|style|title)$/i;let _=0;const E={features:[],filterItem:()=>!0,onScroll:()=>{}};exports.Buttons=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},o),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){s(this,"prxy",t),this._render()}destroy(){this._remove(),i(this)}update(){this._render()}_render(){const t=e(this,"prxy"),s=e(this,"conf"),{el:n,mask:i,pages:o,pageIndex:l}=t,[a,h]=e(this,"btns",(()=>{const t=null!=i?i:n,{template:e,className:o,previousClassName:l,previousLabel:a,previousTitle:h,nextClassName:d,nextLabel:c,nextTitle:u}=s;return[{controls:n.id,label:c,title:u,className:[o,d].join(" "),handler:this._onNext},{controls:n.id,label:a,title:h,className:[o,l].join(" "),handler:this._onPrev}].map((s=>{var n,{handler:i}=s,o=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i{var e;null==t||t.removeEventListener("click",this._onPrev),null==t||t.removeEventListener("click",this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=e(this,"prxy"),{pages:s,pageIndex:n}=t,i=s[n-1]||s[0];t.index=i}_onNext(){const t=e(this,"prxy"),{pages:s,pageIndex:n}=t,i=s[n+1]||s[s.length-1];t.index=i}},exports.Carousel=class{static resetInstanceCount(){}constructor(t,e={}){if(this.behavior=exports.ScrollBehavior.AUTO,!(t&&t instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof t}" was passed.`);s(this,"element",t),_++,t.id=t.id||`caroucssel-${_}`,s(this,"id",t.id);const n=Object.assign(Object.assign({},E),e);s(this,"config",n);let i=null,r=[...n.features];const o=n.features.findIndex((t=>t instanceof m));o>-1&&([i]=r.splice(o,1)),null!=i||(i=new m),r=r.filter((t=>!(t instanceof m))),r=[i,...r],s(this,"mask",i);const l=new f(this,r);switch(s(this,"proxy",l),s(this,"feautres",r),r.forEach((t=>t.init(l))),!0){case Array.isArray(e.index):this.index=e.index;break;case!isNaN(e.index):this.index=[e.index]}this.behavior=exports.ScrollBehavior.SMOOTH,this._onScroll=x(this._onScroll.bind(this),45),this._onResize=x(this._onResize.bind(this),25),t.addEventListener("scroll",this._onScroll),window.addEventListener("resize",this._onResize)}get el(){return e(this,"element")}get mask(){var t;return null!==(t=e(this,"mask").el)&&void 0!==t?t:null}get id(){return e(this,"id")}get index(){return e(this,"index",(()=>{const{el:t,items:e}=this,{length:s}=e,{clientWidth:n}=t,i=t.getBoundingClientRect().left,r=[];let o=0;for(;o=0&&l+.75*s<=n&&r.push(o)}return 0===r.length?[0]:r}))}set index(t){const{behavior:e,el:s,items:i}=this,{length:r}=i;if(!Array.isArray(t)||!t.length)return;let o=t[0]||0;o=Math.max(Math.min(o,r-1),0);const{scrollLeft:l}=s,a=l,h={left:i[o].offsetLeft};o===this.pages[0][0]&&(h.left=0),a!==h.left&&(n(this,"index"),s.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return e(this,"items",(()=>{const{filterItem:t}=e(this,"config"),{el:s}=this;return Array.from(s.children).filter((t=>!b.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return e(this,"pages",(()=>{const{el:t,items:e}=this,{clientWidth:s}=t;if(0===s)return e.map(((t,e)=>[e]));let n=[[]];return e.map(((t,e)=>{const{offsetLeft:s,clientWidth:n}=t;return{left:s,width:n,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:i}=t,r=n[n.length-1],o=r[0];let l=(null==o?void 0:o.left)||0;r===n[0]&&(l=0);let a=Math.floor((e-l+.75*i)/s);for(;a>0;)n.push([]),a--;n[n.length-1].push(t)})),n=n.filter((t=>0!==t.length)),n.map((t=>t.map((({index:t})=>t))))}))}get pageIndex(){return e(this,"page-index",(()=>{const{el:t,items:e,index:s,pages:n}=this,i=t.getBoundingClientRect().left,{clientWidth:r}=t;let o=s.reduce(((t,s)=>{if(!e[s])return t;let{left:n,right:o}=e[s].getBoundingClientRect();return n=Math.round(n-i),o=Math.round(o-i),n<0||r{const n=e[t].getBoundingClientRect().right;return e[s].getBoundingClientRect().right-n}))[0];return n.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;y.test(t.id)&&t.removeAttribute("id");e(this,"feautres").forEach((t=>t.destroy())),t.removeEventListener("scroll",this._onScroll),window.removeEventListener("resize",this._onResize),i(this)}update(){n(this,"index"),n(this,"items"),n(this,"pages"),n(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.FORCED})))}_onScroll(t){n(this,"index"),n(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.SCROLL})));const{index:s}=this;e(this,"config").onScroll({index:s,type:"scroll",target:this,originalEvent:t})}_onResize(){n(this,"pages"),n(this,"index"),n(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.RESIZE})))}},exports.Mask=m,exports.Mouse=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},a),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){s(this,"prxy",t);const n=e(this,"conf"),{el:i}=t;i.style.cursor=n.indicator?"grab":"",i.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){i(this)}update(){}_onStart(t){var s;const n=e(this,"time");clearTimeout(n);const i=e(this,"conf"),r=e(this,"prxy"),o=r.el;e(this,"scrl",(()=>o.scrollLeft)),e(this,"posx",(()=>l(t))),e(this,"pgidx",(()=>r.pageIndex)),o.style.userSelect="none",o.style.scrollBehavior="auto",o.style.scrollSnapType="none",o.style.cursor=i.indicator?"grabbing":"",window.addEventListener("mousemove",this._onDrag,{passive:!0}),window.addEventListener("mouseup",this._onEnd,{passive:!0}),null===(s=i.onStart)||void 0===s||s.call(i,{originalEvent:t})}_onDrag(t){var s,n,i;const r=e(this,"conf"),{el:o}=e(this,"prxy"),a=null!==(s=e(this,"scrl"))&&void 0!==s?s:0,h=(null!==(n=e(this,"posx"))&&void 0!==n?n:0)-l(t);o.scrollLeft=a+h,null===(i=r.onDrag)||void 0===i||i.call(r,{originalEvent:t})}_onEnd(t){var i,r,o,l;const a=e(this,"prxy"),h=e(this,"conf"),d=null!==(i=e(this,"scrl"))&&void 0!==i?i:0,c=null!==(r=e(this,"pgidx"))&&void 0!==r?r:0;n(this,"scrl"),n(this,"posx"),n(this,"pgidx");const u=a.el,p=Math.min(Math.max(100,.25*u.clientWidth),250),g=u.scrollLeft-d,m=Math.abs(g);u.style.removeProperty("user-select"),u.style.removeProperty("scroll-behavior"),u.style.cursor=h.indicator?"grab":"";let v=a.index;if(m>p){const t=g/m,e=Math.max(c+t,0);v=null!==(o=a.pages[e])&&void 0!==o?o:v}window.requestAnimationFrame((()=>{a.index=v}));s(this,"time",window.setTimeout((()=>{u.style.removeProperty("scroll-snap-type")}),1e3)),window.removeEventListener("mousemove",this._onDrag),window.removeEventListener("mouseup",this._onEnd),null===(l=h.onEnd)||void 0===l||l.call(h,{originalEvent:t})}},exports.Pagination=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},c),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){s(this,"prxy",t),this._add()}destroy(){this._remove(),i(this)}update(t){if(t.type===exports.UpdateType.SCROLL)this._update();else this._remove(),this._add()}_add(){var t;const n=e(this,"prxy"),i=e(this,"conf"),{el:o,mask:l,pages:a}=n,h=null!=l?l:o;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=i,g=r(d,{label:u,title:p,pages:a,className:c,controls:o.id});if(!g)return;const m=Array.from(g.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(g),s(this,"pags",g),s(this,"btns",m),this._update()}_update(){const t=e(this,"prxy"),s=e(this,"btns"),{pageIndex:n}=t;null==s||s.forEach(((t,e)=>t.disabled=e===n))}_remove(){var t;const s=e(this,"pags"),i=e(this,"btns");null==i||i.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==s?void 0:s.parentNode)||void 0===t||t.removeChild(s),n(this,"btns"),n(this,"pags")}_onClick(t){const s=e(this,"prxy"),n=e(this,"btns");if(!n)return;const i=t.currentTarget,r=n.indexOf(i);s.index=s.pages[r]}},exports.version="1.1.3";
+"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),"function"==typeof SuppressedError&&SuppressedError;const t=new WeakMap;function e(e,s,n){const i=t.get(e)||new Map;if(i.has(s))return i.get(s);if(!n)return;const o=n();return i.set(s,o),t.set(e,i),o}function s(e,s,n){const i=t.get(e)||new Map;i.set(s,n),t.set(e,i)}function n(e,s){const n=t.get(e);n&&n.has(s)&&n.delete(s)}function i(e){t.delete(e)}function o(t,e){const s=document.createElement("div");s.innerHTML=t(e);const n=s.firstElementChild;return n||null}const r="prxy",l="conf",a="btns",h="click",d={template:({className:t,controls:e,label:s,title:n})=>`\n\t\t\n\t`,className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};const c="prxy",u="conf",p="pgidx",v="posx",g="scrl",m="time",f="grab",x="mousemove",y="mouseup";function b(t){return t instanceof MouseEvent?t.clientX:0}const _={indicator:!1};var E,w;exports.UpdateType=void 0,(E=exports.UpdateType||(exports.UpdateType={})).SCROLL="scroll",E.RESIZE="resize",E.FORCED="forced",E.FEATURE="feature",exports.ScrollBehavior=void 0,(w=exports.ScrollBehavior||(exports.ScrollBehavior={})).AUTO="auto",w.SMOOTH="smooth";const N="prxy",O="conf",C="pags",S="btns",L={template:({className:t,controls:e,pages:s,label:n,title:i})=>`\n\t\t\n\t\t\t${s.map(((t,o)=>{const r={index:o,page:t,pages:s},l=n(r),a=i(r);return`- \n\t\t\t\t\t\n\t\t\t\t
`})).join("")}\n\t\t
\n\t`,className:"pagination",label:({index:t})=>`${t+1}`,title:({index:t})=>`Go to ${t+1}. page`};const T="dims";class R{constructor(){window.addEventListener("resize",(()=>{n(this,T)}))}get dimensions(){return e(this,T,(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const s=t.offsetHeight;e.style.overflow="scroll";let n=t.offsetHeight;n=s===n?e.clientHeight:n;const i=s-n;return document.body.removeChild(e),{height:i}}))}}const k="prxy",j="conf",M="mask",I="hght";let $;const B={enabled:!0,className:"caroucssel-mask",tagName:"div"};class A{constructor(t={}){s(this,j,Object.assign(Object.assign({},B),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=e(this,M))&&void 0!==t?t:null}init(t){s(this,k,t),$=null!=$?$:new R,this._render()}destroy(){this._remove(),i(this)}update(t){switch(t.type){case exports.UpdateType.RESIZE:case exports.UpdateType.FORCED:n(this,I),this._render();break;default:this._render()}}_render(){const{enabled:t,className:n,tagName:i}=e(this,j);if(!t)return;const o=e(this,k).el;let{height:r}=$.dimensions;o.scrollWidth<=o.clientWidth&&(r=0),e(this,M,(()=>{var t;const e=document.createElement(i);return e.className=n,e.style.overflow="hidden",e.style.height="100%",null===(t=o.parentNode)||void 0===t||t.insertBefore(e,o),e.appendChild(o),e}));r!==e(this,I)&&(s(this,I,r),o.style.height=`calc(100% + ${r}px)`,o.style.marginBottom=-1*r+"px")}_remove(){var t,s;const{el:n}=e(this,k),i=e(this,M);null===(t=null==i?void 0:i.parentNode)||void 0===t||t.insertBefore(n,i),null===(s=null==i?void 0:i.parentNode)||void 0===s||s.removeChild(i),n.removeAttribute("style")}}const P="inst",U="feat";function D(t){return e(t,P)}class z{constructor(t,e){s(this,P,t),s(this,U,e)}get id(){return D(this).id}get el(){return D(this).el}get mask(){return D(this).mask}get index(){return D(this).index}set index(t){D(this).index=t}get items(){return D(this).items}get pages(){return D(this).pages}get pageIndex(){return D(this).pageIndex}update(t){var s;D(this).update(),(s=this,e(s,U)).forEach((e=>{e!==t&&e.update({type:exports.UpdateType.FEATURE})}))}}function W(t,e){let s=null;return(...n)=>{null!==s&&clearTimeout(s),s=setTimeout((()=>t(...n)),e)}}const F=/^caroucssel-[0-9]*$/,H="scroll",G="resize",Z="element",q="config",V="index",X="items",J="pages",K="page-index",Q="mask",Y="feautres",tt=.25,et=/^(link|meta|noscript|script|style|title)$/i;let st=0;const nt={features:[],filterItem:()=>!0,onScroll:()=>{}};exports.Buttons=class{constructor(t={}){s(this,l,Object.assign(Object.assign({},d),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){s(this,r,t),this._render()}destroy(){this._remove(),i(this)}update(){this._render()}_render(){const t=e(this,r),s=e(this,l),{el:n,mask:i,pages:d,pageIndex:c}=t,[u,p]=e(this,a,(()=>{const t=null!=i?i:n,{template:e,className:r,previousClassName:l,previousLabel:a,previousTitle:d,nextClassName:c,nextLabel:u,nextTitle:p}=s;return[{controls:n.id,label:u,title:p,className:[r,c].join(" "),handler:this._onNext},{controls:n.id,label:a,title:d,className:[r,l].join(" "),handler:this._onPrev}].map((s=>{var n,{handler:i}=s,r=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i{var e;null==t||t.removeEventListener(h,this._onPrev),null==t||t.removeEventListener(h,this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=e(this,r),{pages:s,pageIndex:n}=t,i=s[n-1]||s[0];t.index=i}_onNext(){const t=e(this,r),{pages:s,pageIndex:n}=t,i=s[n+1]||s[s.length-1];t.index=i}},exports.Carousel=class{static resetInstanceCount(){}constructor(t,e={}){if(this.behavior=exports.ScrollBehavior.AUTO,!(t&&t instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof t}" was passed.`);s(this,Z,t),st++,t.id=t.id||`caroucssel-${st}`,s(this,"id",t.id);const n=Object.assign(Object.assign({},nt),e);s(this,q,n);let i=null,o=[...n.features];const r=n.features.findIndex((t=>t instanceof A));r>-1&&([i]=o.splice(r,1)),null!=i||(i=new A),o=o.filter((t=>!(t instanceof A))),o=[i,...o],s(this,Q,i);const l=new z(this,o);switch(s(this,"proxy",l),s(this,Y,o),o.forEach((t=>t.init(l))),!0){case Array.isArray(e.index):this.index=e.index;break;case!isNaN(e.index):this.index=[e.index]}this.behavior=exports.ScrollBehavior.SMOOTH,this._onScroll=W(this._onScroll.bind(this),45),this._onResize=W(this._onResize.bind(this),25),t.addEventListener(H,this._onScroll),window.addEventListener(G,this._onResize)}get el(){return e(this,Z)}get mask(){var t;return null!==(t=e(this,Q).el)&&void 0!==t?t:null}get id(){return e(this,"id")}get index(){return e(this,V,(()=>{const{el:t,items:e}=this,{length:s}=e,{clientWidth:n}=t,i=t.getBoundingClientRect().left,o=[];let r=0;for(;r=0&&l+.75*s<=n&&o.push(r)}return 0===o.length?[0]:o}))}set index(t){const{behavior:e,el:s,items:i}=this,{length:o}=i;if(!Array.isArray(t)||!t.length)return;let r=t[0]||0;r=Math.max(Math.min(r,o-1),0);const{scrollLeft:l}=s,a=l,h={left:i[r].offsetLeft};r===this.pages[0][0]&&(h.left=0),a!==h.left&&(n(this,V),s.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return e(this,X,(()=>{const{filterItem:t}=e(this,q),{el:s}=this;return Array.from(s.children).filter((t=>!et.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return e(this,J,(()=>{const{el:t,items:e}=this,{clientWidth:s}=t;if(0===s)return e.map(((t,e)=>[e]));let n=[[]];return e.map(((t,e)=>{const{offsetLeft:s,clientWidth:n}=t;return{left:s,width:n,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:i}=t,o=n[n.length-1],r=o[0];let l=(null==r?void 0:r.left)||0;o===n[0]&&(l=0);let a=Math.floor((e-l+.75*i)/s);for(;a>0;)n.push([]),a--;n[n.length-1].push(t)})),n=n.filter((t=>0!==t.length)),n.map((t=>t.map((({index:t})=>t))))}))}get pageIndex(){return e(this,K,(()=>{const{el:t,items:e,index:s,pages:n}=this,i=t.getBoundingClientRect().left,{clientWidth:o}=t;let r=s.reduce(((t,s)=>{if(!e[s])return t;let{left:n,right:r}=e[s].getBoundingClientRect();return n=Math.round(n-i),r=Math.round(r-i),n<0||o{const n=e[t].getBoundingClientRect().right;return e[s].getBoundingClientRect().right-n}))[0];return n.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;F.test(t.id)&&t.removeAttribute("id");e(this,Y).forEach((t=>t.destroy())),t.removeEventListener(H,this._onScroll),window.removeEventListener(G,this._onResize),i(this)}update(){n(this,V),n(this,X),n(this,J),n(this,K);e(this,Y).forEach((t=>t.update({type:exports.UpdateType.FORCED})))}_onScroll(t){n(this,V),n(this,K);e(this,Y).forEach((t=>t.update({type:exports.UpdateType.SCROLL})));const{index:s}=this;e(this,q).onScroll({index:s,type:H,target:this,originalEvent:t})}_onResize(){n(this,J),n(this,V),n(this,K);e(this,Y).forEach((t=>t.update({type:exports.UpdateType.RESIZE})))}},exports.Mask=A,exports.Mouse=class{constructor(t={}){s(this,u,Object.assign(Object.assign({},_),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){s(this,c,t);const n=e(this,u),{el:i}=t;i.style.cursor=n.indicator?f:"",i.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){i(this)}update(){}_onStart(t){var s;const n=e(this,m);clearTimeout(n);const i=e(this,u),o=e(this,c),r=o.el;e(this,g,(()=>r.scrollLeft)),e(this,v,(()=>b(t))),e(this,p,(()=>o.pageIndex)),r.style.userSelect="none",r.style.scrollBehavior="auto",r.style.scrollSnapType="none",r.style.cursor=i.indicator?"grabbing":"",window.addEventListener(x,this._onDrag,{passive:!0}),window.addEventListener(y,this._onEnd,{passive:!0}),null===(s=i.onStart)||void 0===s||s.call(i,{originalEvent:t})}_onDrag(t){var s,n,i;const o=e(this,u),{el:r}=e(this,c),l=null!==(s=e(this,g))&&void 0!==s?s:0,a=(null!==(n=e(this,v))&&void 0!==n?n:0)-b(t);r.scrollLeft=l+a,null===(i=o.onDrag)||void 0===i||i.call(o,{originalEvent:t})}_onEnd(t){var i,o,r,l;const a=e(this,c),h=e(this,u),d=null!==(i=e(this,g))&&void 0!==i?i:0,b=null!==(o=e(this,p))&&void 0!==o?o:0;n(this,g),n(this,v),n(this,p);const _=a.el,E=Math.min(Math.max(100,.25*_.clientWidth),250),w=_.scrollLeft-d,N=Math.abs(w);_.style.removeProperty("user-select"),_.style.removeProperty("scroll-behavior"),_.style.cursor=h.indicator?f:"";let O=a.index;if(N>E){const t=w/N,e=Math.max(b+t,0);O=null!==(r=a.pages[e])&&void 0!==r?r:O}window.requestAnimationFrame((()=>{a.index=O}));const C=window.setTimeout((()=>{_.style.removeProperty("scroll-snap-type")}),1e3);s(this,m,C),window.removeEventListener(x,this._onDrag),window.removeEventListener(y,this._onEnd),null===(l=h.onEnd)||void 0===l||l.call(h,{originalEvent:t})}},exports.Pagination=class{constructor(t={}){s(this,O,Object.assign(Object.assign({},L),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){s(this,N,t),this._add()}destroy(){this._remove(),i(this)}update(t){if(t.type===exports.UpdateType.SCROLL)this._update();else this._remove(),this._add()}_add(){var t;const n=e(this,N),i=e(this,O),{el:r,mask:l,pages:a}=n,h=null!=l?l:r;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=i,v=o(d,{label:u,title:p,pages:a,className:c,controls:r.id});if(!v)return;const g=Array.from(v.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(v),s(this,C,v),s(this,S,g),this._update()}_update(){const t=e(this,N),s=e(this,S),{pageIndex:n}=t;null==s||s.forEach(((t,e)=>t.disabled=e===n))}_remove(){var t;const s=e(this,C),i=e(this,S);null==i||i.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==s?void 0:s.parentNode)||void 0===t||t.removeChild(s),n(this,S),n(this,C)}_onClick(t){const s=e(this,N),n=e(this,S);if(!n)return;const i=t.currentTarget,o=n.indexOf(i);s.index=s.pages[o]}},exports.version="1.1.4";
diff --git a/dist/formats/iife/caroucssel.js b/dist/formats/iife/caroucssel.js
index 69ba985c..9b6ec269 100644
--- a/dist/formats/iife/caroucssel.js
+++ b/dist/formats/iife/caroucssel.js
@@ -12,6 +12,10 @@ var caroucssel = (function (exports) {
}
return t;
}
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
+ var e = new Error(message);
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
+ };
const __CACHE = new WeakMap();
function fromCache(ref, key, factory) {
@@ -797,7 +801,7 @@ var caroucssel = (function (exports) {
}
}
- const version = '1.1.3';
+ const version = '1.1.4';
exports.Buttons = Buttons;
exports.Carousel = Carousel;
diff --git a/dist/formats/iife/caroucssel.min.js b/dist/formats/iife/caroucssel.min.js
index 75d18e88..522e0f99 100644
--- a/dist/formats/iife/caroucssel.min.js
+++ b/dist/formats/iife/caroucssel.min.js
@@ -1 +1 @@
-var caroucssel=function(t){"use strict";const e=new WeakMap;function n(t,n,i){const s=e.get(t)||new Map;if(s.has(n))return s.get(n);if(!i)return;const o=i();return s.set(n,o),e.set(t,s),o}function i(t,n,i){const s=e.get(t)||new Map;s.set(n,i),e.set(t,s)}function s(t,n){const i=e.get(t);i&&i.has(n)&&i.delete(n)}function o(t){e.delete(t)}function r(t,e){const n=document.createElement("div");n.innerHTML=t(e);const i=n.firstElementChild;return i||null}const l="prxy",a="conf",h="btns",d="click",c={template:({className:t,controls:e,label:n,title:i})=>`\n\t\t\n\t`,className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};const u="prxy",p="conf",v="pgidx",g="posx",m="scrl",f="time",y="grab",b="mousemove",x="mouseup";function _(t){return t instanceof MouseEvent?t.clientX:0}const E={indicator:!1};var w,N;t.UpdateType=void 0,(w=t.UpdateType||(t.UpdateType={})).SCROLL="scroll",w.RESIZE="resize",w.FORCED="forced",w.FEATURE="feature",t.ScrollBehavior=void 0,(N=t.ScrollBehavior||(t.ScrollBehavior={})).AUTO="auto",N.SMOOTH="smooth";const O="prxy",C="conf",L="pags",S="btns",T={template:({className:t,controls:e,pages:n,label:i,title:s})=>`\n\t\t\n\t\t\t${n.map(((t,o)=>{const r={index:o,page:t,pages:n},l=i(r),a=s(r);return`- \n\t\t\t\t\t\n\t\t\t\t
`})).join("")}\n\t\t
\n\t`,className:"pagination",label:({index:t})=>`${t+1}`,title:({index:t})=>`Go to ${t+1}. page`};const R="dims";class k{constructor(){window.addEventListener("resize",(()=>{s(this,R)}))}get dimensions(){return n(this,R,(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const n=t.offsetHeight;e.style.overflow="scroll";let i=t.offsetHeight;i=n===i?e.clientHeight:i;const s=n-i;return document.body.removeChild(e),{height:s}}))}}const j="prxy",M="conf",I="mask",$="hght";let B;const A={enabled:!0,className:"caroucssel-mask",tagName:"div"};class P{constructor(t={}){i(this,M,Object.assign(Object.assign({},A),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=n(this,I))&&void 0!==t?t:null}init(t){i(this,j,t),B=null!=B?B:new k,this._render()}destroy(){this._remove(),o(this)}update(e){switch(e.type){case t.UpdateType.RESIZE:case t.UpdateType.FORCED:s(this,$),this._render();break;default:this._render()}}_render(){const{enabled:t,className:e,tagName:s}=n(this,M);if(!t)return;const o=n(this,j).el;let{height:r}=B.dimensions;o.scrollWidth<=o.clientWidth&&(r=0),n(this,I,(()=>{var t;const n=document.createElement(s);return n.className=e,n.style.overflow="hidden",n.style.height="100%",null===(t=o.parentNode)||void 0===t||t.insertBefore(n,o),n.appendChild(o),n}));r!==n(this,$)&&(i(this,$,r),o.style.height=`calc(100% + ${r}px)`,o.style.marginBottom=-1*r+"px")}_remove(){var t,e;const{el:i}=n(this,j),s=n(this,I);null===(t=null==s?void 0:s.parentNode)||void 0===t||t.insertBefore(i,s),null===(e=null==s?void 0:s.parentNode)||void 0===e||e.removeChild(s),i.removeAttribute("style")}}const U="inst",D="feat";function z(t){return n(t,U)}class W{constructor(t,e){i(this,U,t),i(this,D,e)}get id(){return z(this).id}get el(){return z(this).el}get mask(){return z(this).mask}get index(){return z(this).index}set index(t){z(this).index=t}get items(){return z(this).items}get pages(){return z(this).pages}get pageIndex(){return z(this).pageIndex}update(e){var i;z(this).update(),(i=this,n(i,D)).forEach((n=>{n!==e&&n.update({type:t.UpdateType.FEATURE})}))}}function F(t,e){let n=null;return(...i)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>t(...i)),e)}}const H=/^caroucssel-[0-9]*$/,G="scroll",Z="resize",q="element",V="config",X="index",J="items",K="pages",Q="page-index",Y="mask",tt="feautres",et=.25,nt=/^(link|meta|noscript|script|style|title)$/i;let it=0;const st={features:[],filterItem:()=>!0,onScroll:()=>{}};return t.Buttons=class{constructor(t={}){i(this,a,Object.assign(Object.assign({},c),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){i(this,l,t),this._render()}destroy(){this._remove(),o(this)}update(){this._render()}_render(){const t=n(this,l),e=n(this,a),{el:i,mask:s,pages:o,pageIndex:c}=t,[u,p]=n(this,h,(()=>{const t=null!=s?s:i,{template:n,className:o,previousClassName:l,previousLabel:a,previousTitle:h,nextClassName:c,nextLabel:u,nextTitle:p}=e;return[{controls:i.id,label:u,title:p,className:[o,c].join(" "),handler:this._onNext},{controls:i.id,label:a,title:h,className:[o,l].join(" "),handler:this._onPrev}].map((e=>{var i,{handler:s}=e,o=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(t);s{var e;null==t||t.removeEventListener(d,this._onPrev),null==t||t.removeEventListener(d,this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=n(this,l),{pages:e,pageIndex:i}=t,s=e[i-1]||e[0];t.index=s}_onNext(){const t=n(this,l),{pages:e,pageIndex:i}=t,s=e[i+1]||e[e.length-1];t.index=s}},t.Carousel=class{static resetInstanceCount(){}constructor(e,n={}){if(this.behavior=t.ScrollBehavior.AUTO,!(e&&e instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof e}" was passed.`);i(this,q,e),it++,e.id=e.id||`caroucssel-${it}`,i(this,"id",e.id);const s=Object.assign(Object.assign({},st),n);i(this,V,s);let o=null,r=[...s.features];const l=s.features.findIndex((t=>t instanceof P));l>-1&&([o]=r.splice(l,1)),null!=o||(o=new P),r=r.filter((t=>!(t instanceof P))),r=[o,...r],i(this,Y,o);const a=new W(this,r);switch(i(this,"proxy",a),i(this,tt,r),r.forEach((t=>t.init(a))),!0){case Array.isArray(n.index):this.index=n.index;break;case!isNaN(n.index):this.index=[n.index]}this.behavior=t.ScrollBehavior.SMOOTH,this._onScroll=F(this._onScroll.bind(this),45),this._onResize=F(this._onResize.bind(this),25),e.addEventListener(G,this._onScroll),window.addEventListener(Z,this._onResize)}get el(){return n(this,q)}get mask(){var t;return null!==(t=n(this,Y).el)&&void 0!==t?t:null}get id(){return n(this,"id")}get index(){return n(this,X,(()=>{const{el:t,items:e}=this,{length:n}=e,{clientWidth:i}=t,s=t.getBoundingClientRect().left,o=[];let r=0;for(;r=0&&l+.75*n<=i&&o.push(r)}return 0===o.length?[0]:o}))}set index(t){const{behavior:e,el:n,items:i}=this,{length:o}=i;if(!Array.isArray(t)||!t.length)return;let r=t[0]||0;r=Math.max(Math.min(r,o-1),0);const{scrollLeft:l}=n,a=l,h={left:i[r].offsetLeft};r===this.pages[0][0]&&(h.left=0),a!==h.left&&(s(this,X),n.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return n(this,J,(()=>{const{filterItem:t}=n(this,V),{el:e}=this;return Array.from(e.children).filter((t=>!nt.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return n(this,K,(()=>{const{el:t,items:e}=this,{clientWidth:n}=t;if(0===n)return e.map(((t,e)=>[e]));let i=[[]];return e.map(((t,e)=>{const{offsetLeft:n,clientWidth:i}=t;return{left:n,width:i,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:s}=t,o=i[i.length-1],r=o[0];let l=(null==r?void 0:r.left)||0;o===i[0]&&(l=0);let a=Math.floor((e-l+.75*s)/n);for(;a>0;)i.push([]),a--;i[i.length-1].push(t)})),i=i.filter((t=>0!==t.length)),i.map((t=>t.map((({index:t})=>t))))}))}get pageIndex(){return n(this,Q,(()=>{const{el:t,items:e,index:n,pages:i}=this,s=t.getBoundingClientRect().left,{clientWidth:o}=t;let r=n.reduce(((t,n)=>{if(!e[n])return t;let{left:i,right:r}=e[n].getBoundingClientRect();return i=Math.round(i-s),r=Math.round(r-s),i<0||o{const i=e[t].getBoundingClientRect().right;return e[n].getBoundingClientRect().right-i}))[0];return i.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;H.test(t.id)&&t.removeAttribute("id");n(this,tt).forEach((t=>t.destroy())),t.removeEventListener(G,this._onScroll),window.removeEventListener(Z,this._onResize),o(this)}update(){s(this,X),s(this,J),s(this,K),s(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.FORCED})))}_onScroll(e){s(this,X),s(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.SCROLL})));const{index:i}=this;n(this,V).onScroll({index:i,type:G,target:this,originalEvent:e})}_onResize(){s(this,K),s(this,X),s(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.RESIZE})))}},t.Mask=P,t.Mouse=class{constructor(t={}){i(this,p,Object.assign(Object.assign({},E),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){i(this,u,t);const e=n(this,p),{el:s}=t;s.style.cursor=e.indicator?y:"",s.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){o(this)}update(){}_onStart(t){var e;const i=n(this,f);clearTimeout(i);const s=n(this,p),o=n(this,u),r=o.el;n(this,m,(()=>r.scrollLeft)),n(this,g,(()=>_(t))),n(this,v,(()=>o.pageIndex)),r.style.userSelect="none",r.style.scrollBehavior="auto",r.style.scrollSnapType="none",r.style.cursor=s.indicator?"grabbing":"",window.addEventListener(b,this._onDrag,{passive:!0}),window.addEventListener(x,this._onEnd,{passive:!0}),null===(e=s.onStart)||void 0===e||e.call(s,{originalEvent:t})}_onDrag(t){var e,i,s;const o=n(this,p),{el:r}=n(this,u),l=null!==(e=n(this,m))&&void 0!==e?e:0,a=(null!==(i=n(this,g))&&void 0!==i?i:0)-_(t);r.scrollLeft=l+a,null===(s=o.onDrag)||void 0===s||s.call(o,{originalEvent:t})}_onEnd(t){var e,o,r,l;const a=n(this,u),h=n(this,p),d=null!==(e=n(this,m))&&void 0!==e?e:0,c=null!==(o=n(this,v))&&void 0!==o?o:0;s(this,m),s(this,g),s(this,v);const _=a.el,E=Math.min(Math.max(100,.25*_.clientWidth),250),w=_.scrollLeft-d,N=Math.abs(w);_.style.removeProperty("user-select"),_.style.removeProperty("scroll-behavior"),_.style.cursor=h.indicator?y:"";let O=a.index;if(N>E){const t=w/N,e=Math.max(c+t,0);O=null!==(r=a.pages[e])&&void 0!==r?r:O}window.requestAnimationFrame((()=>{a.index=O}));const C=window.setTimeout((()=>{_.style.removeProperty("scroll-snap-type")}),1e3);i(this,f,C),window.removeEventListener(b,this._onDrag),window.removeEventListener(x,this._onEnd),null===(l=h.onEnd)||void 0===l||l.call(h,{originalEvent:t})}},t.Pagination=class{constructor(t={}){i(this,C,Object.assign(Object.assign({},T),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){i(this,O,t),this._add()}destroy(){this._remove(),o(this)}update(e){if(e.type===t.UpdateType.SCROLL)this._update();else this._remove(),this._add()}_add(){var t;const e=n(this,O),s=n(this,C),{el:o,mask:l,pages:a}=e,h=null!=l?l:o;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=s,v=r(d,{label:u,title:p,pages:a,className:c,controls:o.id});if(!v)return;const g=Array.from(v.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(v),i(this,L,v),i(this,S,g),this._update()}_update(){const t=n(this,O),e=n(this,S),{pageIndex:i}=t;null==e||e.forEach(((t,e)=>t.disabled=e===i))}_remove(){var t;const e=n(this,L),i=n(this,S);null==i||i.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==e?void 0:e.parentNode)||void 0===t||t.removeChild(e),s(this,S),s(this,L)}_onClick(t){const e=n(this,O),i=n(this,S);if(!i)return;const s=t.currentTarget,o=i.indexOf(s);e.index=e.pages[o]}},t.version="1.1.3",Object.defineProperty(t,"__esModule",{value:!0}),t}({});
+var caroucssel=function(t){"use strict";"function"==typeof SuppressedError&&SuppressedError;const e=new WeakMap;function n(t,n,s){const i=e.get(t)||new Map;if(i.has(n))return i.get(n);if(!s)return;const o=s();return i.set(n,o),e.set(t,i),o}function s(t,n,s){const i=e.get(t)||new Map;i.set(n,s),e.set(t,i)}function i(t,n){const s=e.get(t);s&&s.has(n)&&s.delete(n)}function o(t){e.delete(t)}function r(t,e){const n=document.createElement("div");n.innerHTML=t(e);const s=n.firstElementChild;return s||null}const l="prxy",a="conf",h="btns",d="click",c={template:({className:t,controls:e,label:n,title:s})=>`\n\t\t\n\t`,className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};const u="prxy",p="conf",v="pgidx",g="posx",m="scrl",f="time",y="grab",b="mousemove",x="mouseup";function _(t){return t instanceof MouseEvent?t.clientX:0}const E={indicator:!1};var w,N;t.UpdateType=void 0,(w=t.UpdateType||(t.UpdateType={})).SCROLL="scroll",w.RESIZE="resize",w.FORCED="forced",w.FEATURE="feature",t.ScrollBehavior=void 0,(N=t.ScrollBehavior||(t.ScrollBehavior={})).AUTO="auto",N.SMOOTH="smooth";const O="prxy",C="conf",S="pags",L="btns",T={template:({className:t,controls:e,pages:n,label:s,title:i})=>`\n\t\t\n\t\t\t${n.map(((t,o)=>{const r={index:o,page:t,pages:n},l=s(r),a=i(r);return`- \n\t\t\t\t\t\n\t\t\t\t
`})).join("")}\n\t\t
\n\t`,className:"pagination",label:({index:t})=>`${t+1}`,title:({index:t})=>`Go to ${t+1}. page`};const R="dims";class k{constructor(){window.addEventListener("resize",(()=>{i(this,R)}))}get dimensions(){return n(this,R,(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const n=t.offsetHeight;e.style.overflow="scroll";let s=t.offsetHeight;s=n===s?e.clientHeight:s;const i=n-s;return document.body.removeChild(e),{height:i}}))}}const j="prxy",M="conf",I="mask",$="hght";let B;const A={enabled:!0,className:"caroucssel-mask",tagName:"div"};class P{constructor(t={}){s(this,M,Object.assign(Object.assign({},A),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=n(this,I))&&void 0!==t?t:null}init(t){s(this,j,t),B=null!=B?B:new k,this._render()}destroy(){this._remove(),o(this)}update(e){switch(e.type){case t.UpdateType.RESIZE:case t.UpdateType.FORCED:i(this,$),this._render();break;default:this._render()}}_render(){const{enabled:t,className:e,tagName:i}=n(this,M);if(!t)return;const o=n(this,j).el;let{height:r}=B.dimensions;o.scrollWidth<=o.clientWidth&&(r=0),n(this,I,(()=>{var t;const n=document.createElement(i);return n.className=e,n.style.overflow="hidden",n.style.height="100%",null===(t=o.parentNode)||void 0===t||t.insertBefore(n,o),n.appendChild(o),n}));r!==n(this,$)&&(s(this,$,r),o.style.height=`calc(100% + ${r}px)`,o.style.marginBottom=-1*r+"px")}_remove(){var t,e;const{el:s}=n(this,j),i=n(this,I);null===(t=null==i?void 0:i.parentNode)||void 0===t||t.insertBefore(s,i),null===(e=null==i?void 0:i.parentNode)||void 0===e||e.removeChild(i),s.removeAttribute("style")}}const U="inst",D="feat";function z(t){return n(t,U)}class W{constructor(t,e){s(this,U,t),s(this,D,e)}get id(){return z(this).id}get el(){return z(this).el}get mask(){return z(this).mask}get index(){return z(this).index}set index(t){z(this).index=t}get items(){return z(this).items}get pages(){return z(this).pages}get pageIndex(){return z(this).pageIndex}update(e){var s;z(this).update(),(s=this,n(s,D)).forEach((n=>{n!==e&&n.update({type:t.UpdateType.FEATURE})}))}}function F(t,e){let n=null;return(...s)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>t(...s)),e)}}const H=/^caroucssel-[0-9]*$/,G="scroll",Z="resize",q="element",V="config",X="index",J="items",K="pages",Q="page-index",Y="mask",tt="feautres",et=.25,nt=/^(link|meta|noscript|script|style|title)$/i;let st=0;const it={features:[],filterItem:()=>!0,onScroll:()=>{}};return t.Buttons=class{constructor(t={}){s(this,a,Object.assign(Object.assign({},c),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){s(this,l,t),this._render()}destroy(){this._remove(),o(this)}update(){this._render()}_render(){const t=n(this,l),e=n(this,a),{el:s,mask:i,pages:o,pageIndex:c}=t,[u,p]=n(this,h,(()=>{const t=null!=i?i:s,{template:n,className:o,previousClassName:l,previousLabel:a,previousTitle:h,nextClassName:c,nextLabel:u,nextTitle:p}=e;return[{controls:s.id,label:u,title:p,className:[o,c].join(" "),handler:this._onNext},{controls:s.id,label:a,title:h,className:[o,l].join(" "),handler:this._onPrev}].map((e=>{var s,{handler:i}=e,o=function(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(s=Object.getOwnPropertySymbols(t);i{var e;null==t||t.removeEventListener(d,this._onPrev),null==t||t.removeEventListener(d,this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=n(this,l),{pages:e,pageIndex:s}=t,i=e[s-1]||e[0];t.index=i}_onNext(){const t=n(this,l),{pages:e,pageIndex:s}=t,i=e[s+1]||e[e.length-1];t.index=i}},t.Carousel=class{static resetInstanceCount(){}constructor(e,n={}){if(this.behavior=t.ScrollBehavior.AUTO,!(e&&e instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof e}" was passed.`);s(this,q,e),st++,e.id=e.id||`caroucssel-${st}`,s(this,"id",e.id);const i=Object.assign(Object.assign({},it),n);s(this,V,i);let o=null,r=[...i.features];const l=i.features.findIndex((t=>t instanceof P));l>-1&&([o]=r.splice(l,1)),null!=o||(o=new P),r=r.filter((t=>!(t instanceof P))),r=[o,...r],s(this,Y,o);const a=new W(this,r);switch(s(this,"proxy",a),s(this,tt,r),r.forEach((t=>t.init(a))),!0){case Array.isArray(n.index):this.index=n.index;break;case!isNaN(n.index):this.index=[n.index]}this.behavior=t.ScrollBehavior.SMOOTH,this._onScroll=F(this._onScroll.bind(this),45),this._onResize=F(this._onResize.bind(this),25),e.addEventListener(G,this._onScroll),window.addEventListener(Z,this._onResize)}get el(){return n(this,q)}get mask(){var t;return null!==(t=n(this,Y).el)&&void 0!==t?t:null}get id(){return n(this,"id")}get index(){return n(this,X,(()=>{const{el:t,items:e}=this,{length:n}=e,{clientWidth:s}=t,i=t.getBoundingClientRect().left,o=[];let r=0;for(;r=0&&l+.75*n<=s&&o.push(r)}return 0===o.length?[0]:o}))}set index(t){const{behavior:e,el:n,items:s}=this,{length:o}=s;if(!Array.isArray(t)||!t.length)return;let r=t[0]||0;r=Math.max(Math.min(r,o-1),0);const{scrollLeft:l}=n,a=l,h={left:s[r].offsetLeft};r===this.pages[0][0]&&(h.left=0),a!==h.left&&(i(this,X),n.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return n(this,J,(()=>{const{filterItem:t}=n(this,V),{el:e}=this;return Array.from(e.children).filter((t=>!nt.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return n(this,K,(()=>{const{el:t,items:e}=this,{clientWidth:n}=t;if(0===n)return e.map(((t,e)=>[e]));let s=[[]];return e.map(((t,e)=>{const{offsetLeft:n,clientWidth:s}=t;return{left:n,width:s,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:i}=t,o=s[s.length-1],r=o[0];let l=(null==r?void 0:r.left)||0;o===s[0]&&(l=0);let a=Math.floor((e-l+.75*i)/n);for(;a>0;)s.push([]),a--;s[s.length-1].push(t)})),s=s.filter((t=>0!==t.length)),s.map((t=>t.map((({index:t})=>t))))}))}get pageIndex(){return n(this,Q,(()=>{const{el:t,items:e,index:n,pages:s}=this,i=t.getBoundingClientRect().left,{clientWidth:o}=t;let r=n.reduce(((t,n)=>{if(!e[n])return t;let{left:s,right:r}=e[n].getBoundingClientRect();return s=Math.round(s-i),r=Math.round(r-i),s<0||o{const s=e[t].getBoundingClientRect().right;return e[n].getBoundingClientRect().right-s}))[0];return s.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;H.test(t.id)&&t.removeAttribute("id");n(this,tt).forEach((t=>t.destroy())),t.removeEventListener(G,this._onScroll),window.removeEventListener(Z,this._onResize),o(this)}update(){i(this,X),i(this,J),i(this,K),i(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.FORCED})))}_onScroll(e){i(this,X),i(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.SCROLL})));const{index:s}=this;n(this,V).onScroll({index:s,type:G,target:this,originalEvent:e})}_onResize(){i(this,K),i(this,X),i(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.RESIZE})))}},t.Mask=P,t.Mouse=class{constructor(t={}){s(this,p,Object.assign(Object.assign({},E),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){s(this,u,t);const e=n(this,p),{el:i}=t;i.style.cursor=e.indicator?y:"",i.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){o(this)}update(){}_onStart(t){var e;const s=n(this,f);clearTimeout(s);const i=n(this,p),o=n(this,u),r=o.el;n(this,m,(()=>r.scrollLeft)),n(this,g,(()=>_(t))),n(this,v,(()=>o.pageIndex)),r.style.userSelect="none",r.style.scrollBehavior="auto",r.style.scrollSnapType="none",r.style.cursor=i.indicator?"grabbing":"",window.addEventListener(b,this._onDrag,{passive:!0}),window.addEventListener(x,this._onEnd,{passive:!0}),null===(e=i.onStart)||void 0===e||e.call(i,{originalEvent:t})}_onDrag(t){var e,s,i;const o=n(this,p),{el:r}=n(this,u),l=null!==(e=n(this,m))&&void 0!==e?e:0,a=(null!==(s=n(this,g))&&void 0!==s?s:0)-_(t);r.scrollLeft=l+a,null===(i=o.onDrag)||void 0===i||i.call(o,{originalEvent:t})}_onEnd(t){var e,o,r,l;const a=n(this,u),h=n(this,p),d=null!==(e=n(this,m))&&void 0!==e?e:0,c=null!==(o=n(this,v))&&void 0!==o?o:0;i(this,m),i(this,g),i(this,v);const _=a.el,E=Math.min(Math.max(100,.25*_.clientWidth),250),w=_.scrollLeft-d,N=Math.abs(w);_.style.removeProperty("user-select"),_.style.removeProperty("scroll-behavior"),_.style.cursor=h.indicator?y:"";let O=a.index;if(N>E){const t=w/N,e=Math.max(c+t,0);O=null!==(r=a.pages[e])&&void 0!==r?r:O}window.requestAnimationFrame((()=>{a.index=O}));const C=window.setTimeout((()=>{_.style.removeProperty("scroll-snap-type")}),1e3);s(this,f,C),window.removeEventListener(b,this._onDrag),window.removeEventListener(x,this._onEnd),null===(l=h.onEnd)||void 0===l||l.call(h,{originalEvent:t})}},t.Pagination=class{constructor(t={}){s(this,C,Object.assign(Object.assign({},T),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){s(this,O,t),this._add()}destroy(){this._remove(),o(this)}update(e){if(e.type===t.UpdateType.SCROLL)this._update();else this._remove(),this._add()}_add(){var t;const e=n(this,O),i=n(this,C),{el:o,mask:l,pages:a}=e,h=null!=l?l:o;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=i,v=r(d,{label:u,title:p,pages:a,className:c,controls:o.id});if(!v)return;const g=Array.from(v.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(v),s(this,S,v),s(this,L,g),this._update()}_update(){const t=n(this,O),e=n(this,L),{pageIndex:s}=t;null==e||e.forEach(((t,e)=>t.disabled=e===s))}_remove(){var t;const e=n(this,S),s=n(this,L);null==s||s.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==e?void 0:e.parentNode)||void 0===t||t.removeChild(e),i(this,L),i(this,S)}_onClick(t){const e=n(this,O),s=n(this,L);if(!s)return;const i=t.currentTarget,o=s.indexOf(i);e.index=e.pages[o]}},t.version="1.1.4",Object.defineProperty(t,"__esModule",{value:!0}),t}({});
diff --git a/dist/formats/umd/caroucssel.js b/dist/formats/umd/caroucssel.js
index 9624ef3f..2e34aafe 100644
--- a/dist/formats/umd/caroucssel.js
+++ b/dist/formats/umd/caroucssel.js
@@ -25,6 +25,10 @@
}
return t;
}
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
+ var e = new Error(message);
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
+ };
const __CACHE = new WeakMap();
function fromCache(ref, key, factory) {
const storage = __CACHE.get(ref) || new Map();
@@ -329,7 +333,6 @@
}
_exports.Mouse = Mouse;
var UpdateType;
- _exports.UpdateType = UpdateType;
(function (UpdateType) {
UpdateType["SCROLL"] = "scroll";
UpdateType["RESIZE"] = "resize";
@@ -337,7 +340,6 @@
UpdateType["FEATURE"] = "feature";
})(UpdateType || (_exports.UpdateType = UpdateType = {}));
var ScrollBehavior;
- _exports.ScrollBehavior = ScrollBehavior;
(function (ScrollBehavior) {
ScrollBehavior["AUTO"] = "auto";
ScrollBehavior["SMOOTH"] = "smooth";
@@ -973,6 +975,5 @@
}
}
_exports.Carousel = Carousel;
- const version = '1.1.3';
- _exports.version = version;
+ const version = _exports.version = '1.1.4';
});
diff --git a/dist/formats/umd/caroucssel.min.js b/dist/formats/umd/caroucssel.min.js
index b29a4d5e..a321304d 100644
--- a/dist/formats/umd/caroucssel.min.js
+++ b/dist/formats/umd/caroucssel.min.js
@@ -1 +1 @@
-!function(t,e){if("function"==typeof define&&define.amd)define("caroucssel",["exports"],e);else if("undefined"!=typeof exports)e(exports);else{var n={exports:{}};e(n.exports),t.caroucssel=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.UpdateType=t.ScrollBehavior=t.Pagination=t.Mouse=t.Mask=t.Carousel=t.Buttons=void 0;const e=new WeakMap;function n(t,n,i){const s=e.get(t)||new Map;if(s.has(n))return s.get(n);if(!i)return;const o=i();return s.set(n,o),e.set(t,s),o}function i(t,n,i){const s=e.get(t)||new Map;s.set(n,i),e.set(t,s)}function s(t,n){const i=e.get(t);i&&i.has(n)&&i.delete(n)}function o(t){e.delete(t)}function r(t,e){const n=document.createElement("div");n.innerHTML=t(e);const i=n.firstElementChild;return i||null}const l="prxy",a="conf",h="btns",d="click",c={template:t=>{let{className:e,controls:n,label:i,title:s}=t;return`\n\t\t\n\t`},className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};t.Buttons=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,a,Object.assign(Object.assign({},c),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){i(this,l,t),this._render()}destroy(){this._remove(),o(this)}update(){this._render()}_render(){const t=n(this,l),e=n(this,a),{el:i,mask:s,pages:o,pageIndex:c}=t,[u,p]=n(this,h,(()=>{const t=null!=s?s:i,{template:n,className:o,previousClassName:l,previousLabel:a,previousTitle:h,nextClassName:c,nextLabel:u,nextTitle:p}=e;return[{controls:i.id,label:u,title:p,className:[o,c].join(" "),handler:this._onNext},{controls:i.id,label:a,title:h,className:[o,l].join(" "),handler:this._onPrev}].map((e=>{var i,{handler:s}=e,o=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(t);s{var e;null==t||t.removeEventListener(d,this._onPrev),null==t||t.removeEventListener(d,this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=n(this,l),{pages:e,pageIndex:i}=t,s=e[i-1]||e[0];t.index=s}_onNext(){const t=n(this,l),{pages:e,pageIndex:i}=t,s=e[i+1]||e[e.length-1];t.index=s}};const u="prxy",p="conf",g="pgidx",v="posx",f="scrl",m="time",b="grab",y="mousemove",x="mouseup";function _(t){return t instanceof MouseEvent?t.clientX:0}const E={indicator:!1};var w,N;t.Mouse=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,p,Object.assign(Object.assign({},E),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){i(this,u,t);const e=n(this,p),{el:s}=t;s.style.cursor=e.indicator?b:"",s.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){o(this)}update(){}_onStart(t){var e;const i=n(this,m);clearTimeout(i);const s=n(this,p),o=n(this,u),r=o.el;n(this,f,(()=>r.scrollLeft)),n(this,v,(()=>_(t))),n(this,g,(()=>o.pageIndex)),r.style.userSelect="none",r.style.scrollBehavior="auto",r.style.scrollSnapType="none",r.style.cursor=s.indicator?"grabbing":"",window.addEventListener(y,this._onDrag,{passive:!0}),window.addEventListener(x,this._onEnd,{passive:!0}),null===(e=s.onStart)||void 0===e||e.call(s,{originalEvent:t})}_onDrag(t){var e,i,s;const o=n(this,p),{el:r}=n(this,u),l=null!==(e=n(this,f))&&void 0!==e?e:0,a=(null!==(i=n(this,v))&&void 0!==i?i:0)-_(t);r.scrollLeft=l+a,null===(s=o.onDrag)||void 0===s||s.call(o,{originalEvent:t})}_onEnd(t){var e,o,r,l;const a=n(this,u),h=n(this,p),d=null!==(e=n(this,f))&&void 0!==e?e:0,c=null!==(o=n(this,g))&&void 0!==o?o:0;s(this,f),s(this,v),s(this,g);const _=a.el,E=Math.min(Math.max(100,.25*_.clientWidth),250),w=_.scrollLeft-d,N=Math.abs(w);_.style.removeProperty("user-select"),_.style.removeProperty("scroll-behavior"),_.style.cursor=h.indicator?b:"";let O=a.index;if(N>E){const t=w/N,e=Math.max(c+t,0);O=null!==(r=a.pages[e])&&void 0!==r?r:O}window.requestAnimationFrame((()=>{a.index=O}));const C=window.setTimeout((()=>{_.style.removeProperty("scroll-snap-type")}),1e3);i(this,m,C),window.removeEventListener(y,this._onDrag),window.removeEventListener(x,this._onEnd),null===(l=h.onEnd)||void 0===l||l.call(h,{originalEvent:t})}},t.UpdateType=w,function(t){t.SCROLL="scroll",t.RESIZE="resize",t.FORCED="forced",t.FEATURE="feature"}(w||(t.UpdateType=w={})),t.ScrollBehavior=N,function(t){t.AUTO="auto",t.SMOOTH="smooth"}(N||(t.ScrollBehavior=N={}));const O="prxy",C="conf",L="pags",S="btns",k={template:t=>{let{className:e,controls:n,pages:i,label:s,title:o}=t;return`\n\t\t\n\t\t\t${i.map(((t,e)=>{const r={index:e,page:t,pages:i},l=s(r),a=o(r);return`- \n\t\t\t\t\t\n\t\t\t\t
`})).join("")}\n\t\t
\n\t`},className:"pagination",label:t=>{let{index:e}=t;return`${e+1}`},title:t=>{let{index:e}=t;return`Go to ${e+1}. page`}};t.Pagination=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,C,Object.assign(Object.assign({},k),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){i(this,O,t),this._add()}destroy(){this._remove(),o(this)}update(t){if(t.type===w.SCROLL)this._update();else this._remove(),this._add()}_add(){var t;const e=n(this,O),s=n(this,C),{el:o,mask:l,pages:a}=e,h=null!=l?l:o;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=s,g=r(d,{label:u,title:p,pages:a,className:c,controls:o.id});if(!g)return;const v=Array.from(g.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(g),i(this,L,g),i(this,S,v),this._update()}_update(){const t=n(this,O),e=n(this,S),{pageIndex:i}=t;null==e||e.forEach(((t,e)=>t.disabled=e===i))}_remove(){var t;const e=n(this,L),i=n(this,S);null==i||i.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==e?void 0:e.parentNode)||void 0===t||t.removeChild(e),s(this,S),s(this,L)}_onClick(t){const e=n(this,O),i=n(this,S);if(!i)return;const s=t.currentTarget,o=i.indexOf(s);e.index=e.pages[o]}};const R="dims";class T{constructor(){window.addEventListener("resize",(()=>{s(this,R)}))}get dimensions(){return n(this,R,(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const n=t.offsetHeight;e.style.overflow="scroll";let i=t.offsetHeight;i=n===i?e.clientHeight:i;const s=n-i;return document.body.removeChild(e),{height:s}}))}}const M="prxy",j="conf",I="mask",$="hght";let B;const A={enabled:!0,className:"caroucssel-mask",tagName:"div"};class P{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,j,Object.assign(Object.assign({},A),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=n(this,I))&&void 0!==t?t:null}init(t){i(this,M,t),B=null!=B?B:new T,this._render()}destroy(){this._remove(),o(this)}update(t){switch(t.type){case w.RESIZE:case w.FORCED:s(this,$),this._render();break;default:this._render()}}_render(){const{enabled:t,className:e,tagName:s}=n(this,j);if(!t)return;const o=n(this,M).el;let{height:r}=B.dimensions;o.scrollWidth<=o.clientWidth&&(r=0),n(this,I,(()=>{var t;const n=document.createElement(s);return n.className=e,n.style.overflow="hidden",n.style.height="100%",null===(t=o.parentNode)||void 0===t||t.insertBefore(n,o),n.appendChild(o),n}));r!==n(this,$)&&(i(this,$,r),o.style.height=`calc(100% + ${r}px)`,o.style.marginBottom=-1*r+"px")}_remove(){var t,e;const{el:i}=n(this,M),s=n(this,I);null===(t=null==s?void 0:s.parentNode)||void 0===t||t.insertBefore(i,s),null===(e=null==s?void 0:s.parentNode)||void 0===e||e.removeChild(s),i.removeAttribute("style")}}t.Mask=P;const D="inst",z="feat";function W(t){return n(t,D)}class U{constructor(t,e){i(this,D,t),i(this,z,e)}get id(){return W(this).id}get el(){return W(this).el}get mask(){return W(this).mask}get index(){return W(this).index}set index(t){W(this).index=t}get items(){return W(this).items}get pages(){return W(this).pages}get pageIndex(){return W(this).pageIndex}update(t){var e;W(this).update(),(e=this,n(e,z)).forEach((e=>{e!==t&&e.update({type:w.FEATURE})}))}}function F(t,e){let n=null;return function(){for(var i=arguments.length,s=new Array(i),o=0;ot(...s)),e)}}const H=/^caroucssel-[0-9]*$/,G="scroll",Z="resize",q="element",V="config",X="index",J="items",K="pages",Q="page-index",Y="mask",tt="feautres",et=.25,nt=/^(link|meta|noscript|script|style|title)$/i;let it=0;const st={features:[],filterItem:()=>!0,onScroll:()=>{}};t.Carousel=class{static resetInstanceCount(){}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.behavior=N.AUTO,!(t&&t instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof t}" was passed.`);i(this,q,t),it++,t.id=t.id||`caroucssel-${it}`,i(this,"id",t.id);const n=Object.assign(Object.assign({},st),e);i(this,V,n);let s=null,o=[...n.features];const r=n.features.findIndex((t=>t instanceof P));r>-1&&([s]=o.splice(r,1)),null!=s||(s=new P),o=o.filter((t=>!(t instanceof P))),o=[s,...o],i(this,Y,s);const l=new U(this,o);switch(i(this,"proxy",l),i(this,tt,o),o.forEach((t=>t.init(l))),!0){case Array.isArray(e.index):this.index=e.index;break;case!isNaN(e.index):this.index=[e.index]}this.behavior=N.SMOOTH,this._onScroll=F(this._onScroll.bind(this),45),this._onResize=F(this._onResize.bind(this),25),t.addEventListener(G,this._onScroll),window.addEventListener(Z,this._onResize)}get el(){return n(this,q)}get mask(){var t;return null!==(t=n(this,Y).el)&&void 0!==t?t:null}get id(){return n(this,"id")}get index(){return n(this,X,(()=>{const{el:t,items:e}=this,{length:n}=e,{clientWidth:i}=t,s=t.getBoundingClientRect().left,o=[];let r=0;for(;r=0&&l+.75*n<=i&&o.push(r)}return 0===o.length?[0]:o}))}set index(t){const{behavior:e,el:n,items:i}=this,{length:o}=i;if(!Array.isArray(t)||!t.length)return;let r=t[0]||0;r=Math.max(Math.min(r,o-1),0);const{scrollLeft:l}=n,a=l,h={left:i[r].offsetLeft};r===this.pages[0][0]&&(h.left=0),a!==h.left&&(s(this,X),n.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return n(this,J,(()=>{const{filterItem:t}=n(this,V),{el:e}=this;return Array.from(e.children).filter((t=>!nt.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return n(this,K,(()=>{const{el:t,items:e}=this,{clientWidth:n}=t;if(0===n)return e.map(((t,e)=>[e]));let i=[[]];return e.map(((t,e)=>{const{offsetLeft:n,clientWidth:i}=t;return{left:n,width:i,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:s}=t,o=i[i.length-1],r=o[0];let l=(null==r?void 0:r.left)||0;o===i[0]&&(l=0);let a=Math.floor((e-l+.75*s)/n);for(;a>0;)i.push([]),a--;i[i.length-1].push(t)})),i=i.filter((t=>0!==t.length)),i.map((t=>t.map((t=>{let{index:e}=t;return e}))))}))}get pageIndex(){return n(this,Q,(()=>{const{el:t,items:e,index:n,pages:i}=this,s=t.getBoundingClientRect().left,{clientWidth:o}=t;let r=n.reduce(((t,n)=>{if(!e[n])return t;let{left:i,right:r}=e[n].getBoundingClientRect();return i=Math.round(i-s),r=Math.round(r-s),i<0||o{const i=e[t].getBoundingClientRect().right;return e[n].getBoundingClientRect().right-i}))[0];return i.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;H.test(t.id)&&t.removeAttribute("id");n(this,tt).forEach((t=>t.destroy())),t.removeEventListener(G,this._onScroll),window.removeEventListener(Z,this._onResize),o(this)}update(){s(this,X),s(this,J),s(this,K),s(this,Q);n(this,tt).forEach((t=>t.update({type:w.FORCED})))}_onScroll(t){s(this,X),s(this,Q);n(this,tt).forEach((t=>t.update({type:w.SCROLL})));const{index:e}=this;n(this,V).onScroll({index:e,type:G,target:this,originalEvent:t})}_onResize(){s(this,K),s(this,X),s(this,Q);n(this,tt).forEach((t=>t.update({type:w.RESIZE})))}};t.version="1.1.3"}));
+!function(t,e){if("function"==typeof define&&define.amd)define("caroucssel",["exports"],e);else if("undefined"!=typeof exports)e(exports);else{var n={exports:{}};e(n.exports),t.caroucssel=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.UpdateType=t.ScrollBehavior=t.Pagination=t.Mouse=t.Mask=t.Carousel=t.Buttons=void 0,"function"==typeof SuppressedError&&SuppressedError;const e=new WeakMap;function n(t,n,s){const i=e.get(t)||new Map;if(i.has(n))return i.get(n);if(!s)return;const o=s();return i.set(n,o),e.set(t,i),o}function s(t,n,s){const i=e.get(t)||new Map;i.set(n,s),e.set(t,i)}function i(t,n){const s=e.get(t);s&&s.has(n)&&s.delete(n)}function o(t){e.delete(t)}function r(t,e){const n=document.createElement("div");n.innerHTML=t(e);const s=n.firstElementChild;return s||null}const l="prxy",a="conf",h="btns",d="click",c={template:t=>{let{className:e,controls:n,label:s,title:i}=t;return`\n\t\t\n\t`},className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};t.Buttons=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,a,Object.assign(Object.assign({},c),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){s(this,l,t),this._render()}destroy(){this._remove(),o(this)}update(){this._render()}_render(){const t=n(this,l),e=n(this,a),{el:s,mask:i,pages:o,pageIndex:c}=t,[u,p]=n(this,h,(()=>{const t=null!=i?i:s,{template:n,className:o,previousClassName:l,previousLabel:a,previousTitle:h,nextClassName:c,nextLabel:u,nextTitle:p}=e;return[{controls:s.id,label:u,title:p,className:[o,c].join(" "),handler:this._onNext},{controls:s.id,label:a,title:h,className:[o,l].join(" "),handler:this._onPrev}].map((e=>{var s,{handler:i}=e,o=function(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(s=Object.getOwnPropertySymbols(t);i{var e;null==t||t.removeEventListener(d,this._onPrev),null==t||t.removeEventListener(d,this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=n(this,l),{pages:e,pageIndex:s}=t,i=e[s-1]||e[0];t.index=i}_onNext(){const t=n(this,l),{pages:e,pageIndex:s}=t,i=e[s+1]||e[e.length-1];t.index=i}};const u="prxy",p="conf",g="pgidx",v="posx",f="scrl",m="time",b="grab",y="mousemove",x="mouseup";function _(t){return t instanceof MouseEvent?t.clientX:0}const E={indicator:!1};var w,N;t.Mouse=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,p,Object.assign(Object.assign({},E),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){s(this,u,t);const e=n(this,p),{el:i}=t;i.style.cursor=e.indicator?b:"",i.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){o(this)}update(){}_onStart(t){var e;const s=n(this,m);clearTimeout(s);const i=n(this,p),o=n(this,u),r=o.el;n(this,f,(()=>r.scrollLeft)),n(this,v,(()=>_(t))),n(this,g,(()=>o.pageIndex)),r.style.userSelect="none",r.style.scrollBehavior="auto",r.style.scrollSnapType="none",r.style.cursor=i.indicator?"grabbing":"",window.addEventListener(y,this._onDrag,{passive:!0}),window.addEventListener(x,this._onEnd,{passive:!0}),null===(e=i.onStart)||void 0===e||e.call(i,{originalEvent:t})}_onDrag(t){var e,s,i;const o=n(this,p),{el:r}=n(this,u),l=null!==(e=n(this,f))&&void 0!==e?e:0,a=(null!==(s=n(this,v))&&void 0!==s?s:0)-_(t);r.scrollLeft=l+a,null===(i=o.onDrag)||void 0===i||i.call(o,{originalEvent:t})}_onEnd(t){var e,o,r,l;const a=n(this,u),h=n(this,p),d=null!==(e=n(this,f))&&void 0!==e?e:0,c=null!==(o=n(this,g))&&void 0!==o?o:0;i(this,f),i(this,v),i(this,g);const _=a.el,E=Math.min(Math.max(100,.25*_.clientWidth),250),w=_.scrollLeft-d,N=Math.abs(w);_.style.removeProperty("user-select"),_.style.removeProperty("scroll-behavior"),_.style.cursor=h.indicator?b:"";let O=a.index;if(N>E){const t=w/N,e=Math.max(c+t,0);O=null!==(r=a.pages[e])&&void 0!==r?r:O}window.requestAnimationFrame((()=>{a.index=O}));const C=window.setTimeout((()=>{_.style.removeProperty("scroll-snap-type")}),1e3);s(this,m,C),window.removeEventListener(y,this._onDrag),window.removeEventListener(x,this._onEnd),null===(l=h.onEnd)||void 0===l||l.call(h,{originalEvent:t})}},function(t){t.SCROLL="scroll",t.RESIZE="resize",t.FORCED="forced",t.FEATURE="feature"}(w||(t.UpdateType=w={})),function(t){t.AUTO="auto",t.SMOOTH="smooth"}(N||(t.ScrollBehavior=N={}));const O="prxy",C="conf",L="pags",S="btns",k={template:t=>{let{className:e,controls:n,pages:s,label:i,title:o}=t;return`\n\t\t\n\t\t\t${s.map(((t,e)=>{const r={index:e,page:t,pages:s},l=i(r),a=o(r);return`- \n\t\t\t\t\t\n\t\t\t\t
`})).join("")}\n\t\t
\n\t`},className:"pagination",label:t=>{let{index:e}=t;return`${e+1}`},title:t=>{let{index:e}=t;return`Go to ${e+1}. page`}};t.Pagination=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,C,Object.assign(Object.assign({},k),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){s(this,O,t),this._add()}destroy(){this._remove(),o(this)}update(t){if(t.type===w.SCROLL)this._update();else this._remove(),this._add()}_add(){var t;const e=n(this,O),i=n(this,C),{el:o,mask:l,pages:a}=e,h=null!=l?l:o;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=i,g=r(d,{label:u,title:p,pages:a,className:c,controls:o.id});if(!g)return;const v=Array.from(g.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(g),s(this,L,g),s(this,S,v),this._update()}_update(){const t=n(this,O),e=n(this,S),{pageIndex:s}=t;null==e||e.forEach(((t,e)=>t.disabled=e===s))}_remove(){var t;const e=n(this,L),s=n(this,S);null==s||s.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==e?void 0:e.parentNode)||void 0===t||t.removeChild(e),i(this,S),i(this,L)}_onClick(t){const e=n(this,O),s=n(this,S);if(!s)return;const i=t.currentTarget,o=s.indexOf(i);e.index=e.pages[o]}};const R="dims";class T{constructor(){window.addEventListener("resize",(()=>{i(this,R)}))}get dimensions(){return n(this,R,(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const n=t.offsetHeight;e.style.overflow="scroll";let s=t.offsetHeight;s=n===s?e.clientHeight:s;const i=n-s;return document.body.removeChild(e),{height:i}}))}}const M="prxy",j="conf",I="mask",$="hght";let A;const B={enabled:!0,className:"caroucssel-mask",tagName:"div"};class P{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,j,Object.assign(Object.assign({},B),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=n(this,I))&&void 0!==t?t:null}init(t){s(this,M,t),A=null!=A?A:new T,this._render()}destroy(){this._remove(),o(this)}update(t){switch(t.type){case w.RESIZE:case w.FORCED:i(this,$),this._render();break;default:this._render()}}_render(){const{enabled:t,className:e,tagName:i}=n(this,j);if(!t)return;const o=n(this,M).el;let{height:r}=A.dimensions;o.scrollWidth<=o.clientWidth&&(r=0),n(this,I,(()=>{var t;const n=document.createElement(i);return n.className=e,n.style.overflow="hidden",n.style.height="100%",null===(t=o.parentNode)||void 0===t||t.insertBefore(n,o),n.appendChild(o),n}));r!==n(this,$)&&(s(this,$,r),o.style.height=`calc(100% + ${r}px)`,o.style.marginBottom=-1*r+"px")}_remove(){var t,e;const{el:s}=n(this,M),i=n(this,I);null===(t=null==i?void 0:i.parentNode)||void 0===t||t.insertBefore(s,i),null===(e=null==i?void 0:i.parentNode)||void 0===e||e.removeChild(i),s.removeAttribute("style")}}t.Mask=P;const D="inst",z="feat";function W(t){return n(t,D)}class F{constructor(t,e){s(this,D,t),s(this,z,e)}get id(){return W(this).id}get el(){return W(this).el}get mask(){return W(this).mask}get index(){return W(this).index}set index(t){W(this).index=t}get items(){return W(this).items}get pages(){return W(this).pages}get pageIndex(){return W(this).pageIndex}update(t){var e;W(this).update(),(e=this,n(e,z)).forEach((e=>{e!==t&&e.update({type:w.FEATURE})}))}}function H(t,e){let n=null;return function(){for(var s=arguments.length,i=new Array(s),o=0;ot(...i)),e)}}const U=/^caroucssel-[0-9]*$/,G="scroll",Z="resize",q="element",V="config",X="index",J="items",K="pages",Q="page-index",Y="mask",tt="feautres",et=.25,nt=/^(link|meta|noscript|script|style|title)$/i;let st=0;const it={features:[],filterItem:()=>!0,onScroll:()=>{}};t.Carousel=class{static resetInstanceCount(){}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.behavior=N.AUTO,!(t&&t instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof t}" was passed.`);s(this,q,t),st++,t.id=t.id||`caroucssel-${st}`,s(this,"id",t.id);const n=Object.assign(Object.assign({},it),e);s(this,V,n);let i=null,o=[...n.features];const r=n.features.findIndex((t=>t instanceof P));r>-1&&([i]=o.splice(r,1)),null!=i||(i=new P),o=o.filter((t=>!(t instanceof P))),o=[i,...o],s(this,Y,i);const l=new F(this,o);switch(s(this,"proxy",l),s(this,tt,o),o.forEach((t=>t.init(l))),!0){case Array.isArray(e.index):this.index=e.index;break;case!isNaN(e.index):this.index=[e.index]}this.behavior=N.SMOOTH,this._onScroll=H(this._onScroll.bind(this),45),this._onResize=H(this._onResize.bind(this),25),t.addEventListener(G,this._onScroll),window.addEventListener(Z,this._onResize)}get el(){return n(this,q)}get mask(){var t;return null!==(t=n(this,Y).el)&&void 0!==t?t:null}get id(){return n(this,"id")}get index(){return n(this,X,(()=>{const{el:t,items:e}=this,{length:n}=e,{clientWidth:s}=t,i=t.getBoundingClientRect().left,o=[];let r=0;for(;r=0&&l+.75*n<=s&&o.push(r)}return 0===o.length?[0]:o}))}set index(t){const{behavior:e,el:n,items:s}=this,{length:o}=s;if(!Array.isArray(t)||!t.length)return;let r=t[0]||0;r=Math.max(Math.min(r,o-1),0);const{scrollLeft:l}=n,a=l,h={left:s[r].offsetLeft};r===this.pages[0][0]&&(h.left=0),a!==h.left&&(i(this,X),n.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return n(this,J,(()=>{const{filterItem:t}=n(this,V),{el:e}=this;return Array.from(e.children).filter((t=>!nt.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return n(this,K,(()=>{const{el:t,items:e}=this,{clientWidth:n}=t;if(0===n)return e.map(((t,e)=>[e]));let s=[[]];return e.map(((t,e)=>{const{offsetLeft:n,clientWidth:s}=t;return{left:n,width:s,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:i}=t,o=s[s.length-1],r=o[0];let l=(null==r?void 0:r.left)||0;o===s[0]&&(l=0);let a=Math.floor((e-l+.75*i)/n);for(;a>0;)s.push([]),a--;s[s.length-1].push(t)})),s=s.filter((t=>0!==t.length)),s.map((t=>t.map((t=>{let{index:e}=t;return e}))))}))}get pageIndex(){return n(this,Q,(()=>{const{el:t,items:e,index:n,pages:s}=this,i=t.getBoundingClientRect().left,{clientWidth:o}=t;let r=n.reduce(((t,n)=>{if(!e[n])return t;let{left:s,right:r}=e[n].getBoundingClientRect();return s=Math.round(s-i),r=Math.round(r-i),s<0||o{const s=e[t].getBoundingClientRect().right;return e[n].getBoundingClientRect().right-s}))[0];return s.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;U.test(t.id)&&t.removeAttribute("id");n(this,tt).forEach((t=>t.destroy())),t.removeEventListener(G,this._onScroll),window.removeEventListener(Z,this._onResize),o(this)}update(){i(this,X),i(this,J),i(this,K),i(this,Q);n(this,tt).forEach((t=>t.update({type:w.FORCED})))}_onScroll(t){i(this,X),i(this,Q);n(this,tt).forEach((t=>t.update({type:w.SCROLL})));const{index:e}=this;n(this,V).onScroll({index:e,type:G,target:this,originalEvent:t})}_onResize(){i(this,K),i(this,X),i(this,Q);n(this,tt).forEach((t=>t.update({type:w.RESIZE})))}};t.version="1.1.4"}));
diff --git a/dist/index.d.ts b/dist/index.d.ts
index 77d63d09..004895c9 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -3,4 +3,4 @@ export { Mouse } from './features/mouse';
export { Pagination } from './features/pagination';
export { Carousel, Mask } from './carousel';
export * from './types';
-export declare const version = "1.1.3";
+export declare const version = "1.1.4";
diff --git a/dist/index.js b/dist/index.js
index 7b92984a..d93bc790 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -5,4 +5,4 @@ export { Carousel, Mask } from './carousel';
export * from './types';
// This will be replaced by the version from the package.json
// See: scripts/build_post.js
-export const version = '1.1.3';
+export const version = '1.1.4';
diff --git a/package-lock.json b/package-lock.json
index 3e19c958..7eb1e2da 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "caroucssel",
- "version": "1.1.3",
+ "version": "1.1.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "caroucssel",
- "version": "1.1.3",
+ "version": "1.1.4",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.15.5",
diff --git a/package.json b/package.json
index 5cda6995..1f5a53cb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "caroucssel",
- "version": "1.1.3",
+ "version": "1.1.4",
"description": "A lightweight dependency-free css carousel.",
"module": "index.js",
"main": "formats/cjs/caroucssel.js",