Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

embla-carousel

Package Overview
Dependencies
Maintainers
1
Versions
232
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embla-carousel - npm Package Compare versions

Comparing version 4.3.0 to 4.3.1

29

embla-carousel.esm.js

@@ -530,13 +530,4 @@ function _extends() {

function removeOffset(n) {
if (min === max) return n;
while (reachedMin(n)) {
n += length;
}
while (reachedMax(n)) {
n -= length;
}
return n;
if (!length) return n;
return n - length * Math.ceil((n - max) / length);
}

@@ -1285,7 +1276,7 @@

function OptionsPseudo(node) {
var psuedoString = window.getComputedStyle(node, ':before').content;
var pseudoString = window.getComputedStyle(node, ':before').content;
function get() {
try {
return JSON.parse(psuedoString.slice(1, -1).replace(/\\/g, ''));
return JSON.parse(pseudoString.slice(1, -1).replace(/\\/g, ''));
} catch (error) {} // eslint-disable-line no-empty

@@ -1348,4 +1339,6 @@

var options = _extends({}, defaultOptions);
var optionsBase = _extends({}, defaultOptions);
var options = _extends({}, optionsBase);
var optionsPseudo;

@@ -1368,3 +1361,4 @@ var rootNodeSize = 0;

setupElements();
options = _extends(options, partialOptions, optionsPseudo.get());
optionsBase = _extends({}, optionsBase, partialOptions);
options = _extends({}, optionsBase, optionsPseudo.get());
engine = Engine(sliderRoot, container, slides, options, events);

@@ -1443,6 +1437,3 @@ eventStore.add(window, 'resize', debouncedResize);

});
events.off('select', toggleSelectedClass);
events.off('pointerUp', toggleSelectedClass);
events.off('pointerDown', toggleDraggingClass);
events.off('pointerUp', toggleDraggingClass);
events.off('select', toggleSelectedClass).off('pointerUp', toggleSelectedClass).off('pointerDown', toggleDraggingClass).off('pointerUp', toggleDraggingClass);
}

@@ -1449,0 +1440,0 @@

@@ -532,13 +532,4 @@ 'use strict';

function removeOffset(n) {
if (min === max) return n;
while (reachedMin(n)) {
n += length;
}
while (reachedMax(n)) {
n -= length;
}
return n;
if (!length) return n;
return n - length * Math.ceil((n - max) / length);
}

@@ -1287,7 +1278,7 @@

function OptionsPseudo(node) {
var psuedoString = window.getComputedStyle(node, ':before').content;
var pseudoString = window.getComputedStyle(node, ':before').content;
function get() {
try {
return JSON.parse(psuedoString.slice(1, -1).replace(/\\/g, ''));
return JSON.parse(pseudoString.slice(1, -1).replace(/\\/g, ''));
} catch (error) {} // eslint-disable-line no-empty

@@ -1350,4 +1341,6 @@

var options = _extends({}, defaultOptions);
var optionsBase = _extends({}, defaultOptions);
var options = _extends({}, optionsBase);
var optionsPseudo;

@@ -1370,3 +1363,4 @@ var rootNodeSize = 0;

setupElements();
options = _extends(options, partialOptions, optionsPseudo.get());
optionsBase = _extends({}, optionsBase, partialOptions);
options = _extends({}, optionsBase, optionsPseudo.get());
engine = Engine(sliderRoot, container, slides, options, events);

@@ -1445,6 +1439,3 @@ eventStore.add(window, 'resize', debouncedResize);

});
events.off('select', toggleSelectedClass);
events.off('pointerUp', toggleSelectedClass);
events.off('pointerDown', toggleDraggingClass);
events.off('pointerUp', toggleDraggingClass);
events.off('select', toggleSelectedClass).off('pointerUp', toggleSelectedClass).off('pointerDown', toggleDraggingClass).off('pointerUp', toggleDraggingClass);
}

@@ -1451,0 +1442,0 @@

@@ -1,1 +0,1 @@

!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarousel=e()}(this,(function(){"use strict";function n(){return(n=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n}).apply(this,arguments)}function e(n,e){var t={start:function(){return 0},center:function(n){return r(n)/2},end:r};function r(n){return e-n}return{measure:function(r){return"number"==typeof n?e*Number(n):t[n](r)}}}function t(n){return n?n/Math.abs(n):0}function r(n,e){return Math.abs(n-e)}function o(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function i(n){return Object.keys(n).map(Number)}function u(n){return n[a(n)]}function a(n){return Math.max(0,n.length-1)}function c(n,e){var t=n.classList;e&&t.contains(e)&&t.remove(e)}function s(n,e){var t=n.classList;e&&!t.contains(e)&&t.add(e)}function f(){var n=[];var e={add:function(t,r,o,i){return void 0===i&&(i=!1),t.addEventListener(r,o,i),n.push((function(){return t.removeEventListener(r,o,i)})),e},removeAll:function(){return n=n.filter((function(n){return n()})),e}};return e}function d(n){var e=n;function t(n){return e/=n,o}function r(n){return"number"==typeof n?n:n.get()}var o={add:function(n){return e+=r(n),o},divide:t,get:function(){return e},multiply:function(n){return e*=n,o},normalize:function(){return 0!==e&&t(e),o},set:function(n){return e=r(n),o},subtract:function(n){return e-=r(n),o}};return o}function l(n,e,o,i,u,a,c,s,l,p,g,m,v,h){var x=n.scroll,y=n.cross,b=["INPUT","SELECT","TEXTAREA"],w=d(0),M=d(0),S=d(0),E=f(),A=f(),T={mouse:2.5,touch:3.5},C={mouse:5,touch:7},D=u?5:12,P=!1,B=!1,I=!1,L=!1;function z(n){if(!(L="mousedown"===n.type)||0===n.button){var e,t,u=r(i.get(),c.get())>=2,s=L||!u,f=(e=n.target,t=e.nodeName||"",!(b.indexOf(t)>-1)),d=u||L&&f;P=!0,a.pointerDown(n),S.set(i),i.set(c),p.useBaseMass().useSpeed(80),function(){var n=L?document:o;A.add(n,"touchmove",O).add(n,"touchend",k).add(n,"mousemove",O).add(n,"mouseup",k)}(),w.set(a.readPoint(n,x)),M.set(a.readPoint(n,y)),h.emit("pointerDown"),s&&(I=!1),d&&n.preventDefault()}}function O(n){if(!B&&!L){if(!n.cancelable)return k();var t=a.readPoint(n,x).get(),o=a.readPoint(n,y).get(),u=r(t,w.get()),c=r(o,M.get());if(!(B=u>c)&&!I)return k()}var f=a.pointerMove(n);!I&&f&&(I=!0),s.start(),i.add(e.applyTo(f)),n.preventDefault()}function k(){var n=a.pointerUp()*(u?C:T)[L?"mouse":"touch"],o=function(n){var e=!(g.byDistance(0,!1).index!==m.get())&&Math.abs(n)>4,r=n+c.get();if(e&&!u&&!v.reachedAny(r)){var o=m.clone().add(-1*t(n));return g.byIndex(o.get(),0).distance}return g.byDistance(n,!u).distance}(e.applyTo(n)),s=function(n,e){if(0===n||0===e)return 0;if(Math.abs(n)<=Math.abs(e))return 0;var t=r(Math.abs(n),Math.abs(e));return Math.abs(t/n)}(n,o);r(i.get(),S.get())>=.5&&!L&&(I=!0),B=!1,P=!1,A.removeAll(),p.useSpeed(D+D*s),l.distance(o,!u),L=!1,h.emit("pointerUp")}function N(n){I&&n.preventDefault()}return{addActivationEvents:function(){var n=o;E.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",z).add(n,"mousedown",z).add(n,"touchcancel",k).add(n,"contextmenu",k).add(n,"click",N)},clickAllowed:function(){return!I},pointerDown:function(){return P},removeAllEvents:function(){E.removeAll(),A.removeAll()}}}function p(n,e){var t=Math.abs(n-e);function r(e){return e<n}function o(n){return n>e}function i(n){return r(n)||o(n)}return{constrain:function(t){return i(t)?r(t)?n:e:t},length:t,loop:function(t){return i(t)?r(t)?e:n:t},max:e,min:n,reachedAny:i,reachedMax:o,reachedMin:r,removeOffset:function(i){if(n===e)return i;for(;r(i);)i+=t;for(;o(i);)i-=t;return i}}}function g(n,e,r){var o,i,u=(o=2,i=Math.pow(10,o),function(n){return Math.round(n*i)/i}),a=d(0),c=d(0),s=d(0),f=0,l=e,p=r;function g(n){return l=n,v}function m(n){return p=n,v}var v={direction:function(){return f},seek:function(e){s.set(e).subtract(n);var r,o,i,u=(r=s.get(),(i=0)+(r-(o=0))/(100-o)*(l-i));return f=t(s.get()),s.normalize().multiply(u).subtract(a),function(n){n.divide(p),c.add(n)}(s),v},settle:function(e){var t=e.get()-n.get(),r=!u(t);return r&&n.set(e),r},update:function(){a.add(c),n.add(a),c.multiply(0)},useBaseMass:function(){return m(r)},useBaseSpeed:function(){return g(e)},useMass:m,useSpeed:g};return v}function m(n,e,t){var r=!1;return{constrain:function(o,i){if(function(t){return!r&&(!!n.reachedAny(t.get())&&!!n.reachedAny(e.get()))}(o)){var u=i?.7:.4,a=o.get()-e.get();o.subtract(a*u),!i&&Math.abs(a)<10&&(o.set(n.constrain(o.get())),t.useSpeed(10).useMass(3))}},toggleActive:function(n){r=!n}}}function v(n,e,t,r,o){var i=p(-e+n,t[0]),a=r.map(i.constrain);return{snapsContained:function(){if(e<=n)return[i.max];if("keepSnaps"===o)return a;var t=function(){var n=a[0],e=u(a),t=a.lastIndexOf(n),r=a.indexOf(e)+1;return p(t,r)}(),r=t.min,c=t.max;return a.slice(r,c)}()}}function h(n,e,t,r){var o=p(t.min+e.measure(.1),t.max+e.measure(.1)),i=o.reachedMin,u=o.reachedMax;return{loop:function(e,t){if(function(n){return 1===n?u(r.get()):-1===n&&i(r.get())}(t)){var o=n*(-1*t);e.forEach((function(n){return n.add(o)}))}}}}function x(n){var e=n.max,t=n.length;return{get:function(n){return(n-e)/-t}}}function y(n,e,t,r,i,a){var c,s,f=n.startEdge,d=n.endEdge,l=i.map((function(n){return r[f]-n[f]})).map(t.measure).map((function(n){return-Math.abs(n)})),p=(c=o(l,a).map((function(n){return n[0]})),s=o(i,a).map((function(n){return u(n)[d]-n[0][f]})).map(t.measure).map(Math.abs).map(e.measure),c.map((function(n,e){return n+s[e]})));return{snaps:l,snapsAligned:p}}function b(n,e,t,r,o,i){var u=o.reachedMax,a=o.reachedAny,c=o.removeOffset;function s(n,e){return Math.abs(n)<Math.abs(e)?n:e}function f(n,t){var o=n,i=n+r,u=n-r;if(!e)return o;if(!t)return s(s(o,i),u);var a=s(o,1===t?i:u);return Math.abs(a)*t}return{byDistance:function(r,o){var s=i.get()+r,d=function(n){var e=c(n);return{index:t.map((function(n){return n-e})).map((function(n){return f(n,0)})).map((function(n,e){return{diff:n,index:e}})).sort((function(n,e){return Math.abs(n.diff)-Math.abs(e.diff)}))[0].index,distance:e}}(s),l=function(t,r){if(!(!e&&a(t)))return r;var o=n.min,i=n.max;return u(t)?o:i}(s,d.index),p=!e&&a(s);return!o||p?{index:l,distance:r}:{index:l,distance:r+f(t[l]-d.distance,0)}},byIndex:function(n,e){return{index:n,distance:f(t[n]-i.get(),e)}},shortcut:f}}function w(n,e,t,r,o,u,a){var c,s=i(r),f=i(r).reverse(),d=(c=o[0]-1,g(p(f,c),"end")).concat(function(){var n=e-o[0]-1;return g(p(s,n),"start")}());function l(n,e){return n.reduce((function(n,e){return n-r[e]}),e)}function p(n,e){return n.reduce((function(n,t){return l(n,e)>0?n.concat([t]):n}),[])}function g(n,e){var r="start"===e,o=r?-t:t,i=u.findSlideBounds(o);return n.map((function(n){var e=r?0:-t,o=r?t:0,u=i.filter((function(e){return e.index===n}))[0][r?"end":"start"];return{point:u,getTarget:function(){return a.get()>u?e:o},index:n,location:-1}}))}return{canLoop:function(){return d.every((function(n){var t=n.index;return l(s.filter((function(n){return n!==t})),e)<=0}))},clear:function(e){d.forEach((function(t){var r=t.index;e[r].style[n.startEdge]=""}))},loop:function(e){d.forEach((function(t){var r=t.getTarget,o=t.location,i=t.index,u=r();u!==o&&(e[i].style[n.startEdge]=u+"%",t.location=u)}))},loopPoints:d}}function M(n,e,t){var r=f(),o=r.removeAll,i=0;function u(n){9===n.keyCode&&(i=(new Date).getTime())}function a(o,u){r.add(o,"focus",(function(){if(!((new Date).getTime()-i>10)){n.scrollLeft=0;var r=Math.floor(u/t);e.index(r,0)}}),!0)}return{addActivationEvents:function(n){r.add(document,"keydown",u,!1),n.forEach(a)},removeAllEvents:o}}function S(n,e,t){var r=t.style,o="x"===n.scroll?function(n){return"translate3d("+n+"%,0px,0px)"}:function(n){return"translate3d(0px,"+n+"%,0px)"},i=!1;return{clear:function(){r.transform=""},to:function(n){i||(r.transform=o(e.applyTo(n.get())))},toggleActive:function(n){i=!n}}}function E(n,r,o,c,s){var f,E=c.align,A=c.axis,T=c.direction,C=c.startIndex,D=c.inViewThreshold,P=c.loop,B=c.speed,I=c.dragFree,L=c.slidesToScroll,z=c.containScroll,O=r.getBoundingClientRect(),k=o.map((function(n){return n.getBoundingClientRect()})),N=function(n){var e="rtl"===n?-1:1;return{applyTo:function(n){return n*e}}}(T),F=function(n,e){var t="y"===n?"y":"x";return{scroll:t,cross:"y"===n?"x":"y",startEdge:"y"===t?"top":"rtl"===e?"right":"left",endEdge:"y"===t?"bottom":"rtl"===e?"left":"right",measureSize:function(n){var e=n.width,r=n.height;return"x"===t?e:r}}}(A,T),U=(f=F.measureSize(O),{measure:function(n){return 0===f?0:n/f*100},totalPercent:100}),V=U.totalPercent,H=e(E,V),R=function(n,e,t,r,o){var i=n.measureSize,c=n.startEdge,s=n.endEdge,f=r.map(i);return{slideSizes:f.map(e.measure),slideSizesWithGaps:r.map((function(n,e,r){var i=e===a(r),d=window.getComputedStyle(u(t)),l=parseFloat(d.getPropertyValue("margin-"+s));return i?f[e]+(o?l:0):r[e+1][c]-n[c]})).map(e.measure).map(Math.abs)}}(F,U,o,k,P),j=R.slideSizes,G=R.slideSizesWithGaps,q=y(F,H,U,O,k,L),W=q.snaps,X=q.snapsAligned,J=-1*u(W)+u(G),Y=v(V,J,W,X,z).snapsContained,K=!P&&""!==z?Y:X,Q=function(n,e,t){var r,o;return{limit:(r=e[0],o=u(e),p(t?r-n:o,r))}}(J,K,P).limit,Z=function n(e,r,o){var i=e.min,u=e.max,a=e[r?"loop":"constrain"],c=a(o);function s(){return c}function f(n){return c=a(n),d}var d={add:function n(e){if(0!==e){var r=t(e);return f(s()+r),n(e+-1*r)}return d},clone:function(){return n(e,r,s())},get:s,max:u,min:i,set:f};return d}(p(0,a(K)),P,C),$=Z.clone(),_=i(o),nn=function(n){var e=0;function t(n,t){return function(){n===!!e&&t()}}function r(){e=window.requestAnimationFrame(n)}return{proceed:t(!0,r),start:t(!1,r),stop:t(!0,(function(){window.cancelAnimationFrame(e),e=0}))}}((function(){P||fn.scrollBounds.constrain(rn,fn.dragHandler.pointerDown()),fn.scrollBody.seek(rn).update();var n=fn.scrollBody.settle(rn);n&&!fn.dragHandler.pointerDown()&&(fn.animation.stop(),s.emit("settle")),n||s.emit("scroll"),P&&(fn.scrollLooper.loop(on,fn.scrollBody.direction()),fn.slideLooper.loop(o)),fn.translate.to(tn),fn.animation.proceed()})),en=K[Z.get()],tn=d(en),rn=d(en),on=[tn,rn],un=g(tn,B,1),an=b(Z,P,K,J,Q,rn),cn=function(n,e,t,r,o,i){function u(r){var u=r.distance,a=r.index!==e.get();u&&(n.start(),o.add(u)),a&&(t.set(e.get()),e.set(r.index),i.emit("select"))}return{distance:function(n,e){u(r.byDistance(n,e))},index:function(n,t){var o=e.clone().set(n);u(r.byIndex(o.get(),t))}}}(nn,Z,$,an,rn,s),sn=function(n,e,t,r,o,i){var u=Math.min(Math.max(i,.01),.99),a=(o?[0,e,-e]:[0]).reduce((function(n,e){return n.concat(c(e,u))}),[]);function c(e,o){var i=t.map((function(n){return n*(o||0)}));return r.map((function(r,o){return{start:r-t[o]+i[o]+e,end:r+n-i[o]+e,index:o}}))}return{check:function(n){return a.reduce((function(e,t){var r=t.index,o=t.start,i=t.end;return!(-1!==e.indexOf(r))&&(o<n&&i>n)?e.concat([r]):e}),[])},findSlideBounds:c}}(V,J,j,W,P,D),fn={animation:nn,axis:F,direction:N,dragHandler:l(F,N,n,rn,I,function(n,e){var t=n.scroll,r={x:"clientX",y:"clientY"},o=d(0),i=d(0),u=d(0),a=d(0),c=[],s=(new Date).getTime(),f=!1;function l(n,e){f=!n.touches;var t=r[e],o=f?n[t]:n.touches[0][t];return a.set(o)}return{pointerDown:function(n){var r=l(n,t);return o.set(r),u.set(r),e.measure(o.get())},pointerMove:function(n){var r=l(n,t),o=(new Date).getTime(),a=o-s;return a>=10&&(a>=100&&(c=[]),c.push(r.get()),s=o),i.set(r).subtract(u),u.set(r),e.measure(i.get())},pointerUp:function(){var n=(new Date).getTime()-s,t=u.get(),r=c.slice(-5).map((function(n){return t-n})).sort((function(n,e){return Math.abs(n)<Math.abs(e)?1:-1}))[0];return u.set(n>100||!r?0:r),c=[],e.measure(u.get())},readPoint:l}}(F,U),tn,nn,cn,un,an,Z,Q,s),pxToPercent:U,index:Z,indexPrevious:$,limit:Q,location:tn,options:c,scrollBody:un,scrollBounds:m(Q,tn,un),scrollLooper:h(J,U,Q,tn),scrollProgress:x(Q),scrollSnaps:K,scrollTarget:an,scrollTo:cn,slideFocus:M(n,cn,L),slideLooper:w(F,V,J,G,K,sn,tn),slidesInView:sn,slideIndexes:_,target:rn,translate:S(F,N,r)};return fn}var A={align:"center",axis:"x",containScroll:"",direction:"ltr",dragFree:!1,draggable:!0,draggableClass:"is-draggable",draggingClass:"is-dragging",inViewThreshold:0,loop:!1,selectedClass:"is-selected",slidesToScroll:1,speed:10,startIndex:0};return function(e,t){var r,o,i,u,a,d,l,p=function(){var n={};function e(e){return n[e]||[]}var t={emit:function(n){return e(n).forEach((function(e){return e(n)})),t},off:function(r,o){return n[r]=e(r).filter((function(n){return n!==o})),t},on:function(r,o){return n[r]=e(r).concat([o]),t}};return t}(),g=f(),m=(r=function(){if(y){var n=u.axis.measureSize(e.getBoundingClientRect());w!==n&&P(),p.emit("resize")}},o=500,i=0,function(){window.clearTimeout(i),i=window.setTimeout(r,o)||0}),v=P,h=p.on,x=p.off,y=!1,b=n({},A),w=0;function M(){if(!e)throw new Error("Missing root node 😢");var n,t,r=e.querySelector("*");if(!r)throw new Error("Missing container node 😢");d=r,l=Array.prototype.slice.call(d.children),n=e,t=window.getComputedStyle(n,":before").content,a={get:function(){try{return JSON.parse(t.slice(1,-1).replace(/\\/g,""))}catch(n){}return{}}}}function S(t){if(M(),b=n(b,t,a.get()),u=E(e,d,l,b,p),g.add(window,"resize",m),u.translate.to(u.location),w=u.axis.measureSize(e.getBoundingClientRect()),b.loop){if(!u.slideLooper.canLoop())return D(),S({loop:!1});u.slideLooper.loop(l)}b.draggable&&d.offsetParent&&l.length&&(u.dragHandler.addActivationEvents(),b.draggableClass&&s(e,b.draggableClass),b.draggingClass&&p.on("pointerDown",T).on("pointerUp",T)),l.length&&u.slideFocus.addActivationEvents(l),b.selectedClass&&(C(),p.on("select",C).on("pointerUp",C)),y||(setTimeout((function(){return p.emit("init")}),0),y=!0)}function T(n){var t=b.draggingClass;"pointerDown"===n?s(e,t):c(e,t)}function C(){var n=b.selectedClass,e=B(!0);I(!0).forEach((function(e){return c(l[e],n)})),e.forEach((function(e){return s(l[e],n)}))}function D(){u.dragHandler.removeAllEvents(),u.slideFocus.removeAllEvents(),u.animation.stop(),g.removeAll(),u.translate.clear(),u.slideLooper.clear(l),c(e,b.draggableClass),l.forEach((function(n){return c(n,b.selectedClass)})),p.off("select",C),p.off("pointerUp",C),p.off("pointerDown",T),p.off("pointerUp",T)}function P(e){if(y){var t=n({startIndex:z()},e);D(),S(t),p.emit("reInit")}}function B(n){var e=u[n?"target":"location"].get(),t=b.loop?"removeOffset":"constrain";return u.slidesInView.check(u.limit[t](e))}function I(n){var e=B(n);return u.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}function L(n,e){u.scrollBody.useBaseMass().useBaseSpeed(),y&&u.scrollTo.index(n,e||0)}function z(){return u.index.get()}return S(t),{canScrollNext:function(){return u.index.clone().add(1).get()!==z()},canScrollPrev:function(){return u.index.clone().add(-1).get()!==z()},clickAllowed:function(){return u.dragHandler.clickAllowed()},containerNode:function(){return d},dangerouslyGetEngine:function(){return u},destroy:function(){y&&(D(),y=!1,p.emit("destroy"))},off:x,on:h,previousScrollSnap:function(){return u.indexPrevious.get()},reInit:v,rootNode:function(){return e},scrollNext:function(){L(u.index.clone().add(1).get(),-1)},scrollPrev:function(){L(u.index.clone().add(-1).get(),1)},scrollProgress:function(){return u.scrollProgress.get(u.location.get())},scrollSnapList:function(){return u.scrollSnaps.map(u.scrollProgress.get)},scrollTo:L,selectedScrollSnap:z,slideNodes:function(){return l},slidesInView:B,slidesNotInView:I}}}));
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarousel=e()}(this,(function(){"use strict";function n(){return(n=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n}).apply(this,arguments)}function e(n,e){var t={start:function(){return 0},center:function(n){return r(n)/2},end:r};function r(n){return e-n}return{measure:function(r){return"number"==typeof n?e*Number(n):t[n](r)}}}function t(n){return n?n/Math.abs(n):0}function r(n,e){return Math.abs(n-e)}function o(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function i(n){return Object.keys(n).map(Number)}function a(n){return n[u(n)]}function u(n){return Math.max(0,n.length-1)}function c(n,e){var t=n.classList;e&&t.contains(e)&&t.remove(e)}function s(n,e){var t=n.classList;e&&!t.contains(e)&&t.add(e)}function d(){var n=[];var e={add:function(t,r,o,i){return void 0===i&&(i=!1),t.addEventListener(r,o,i),n.push((function(){return t.removeEventListener(r,o,i)})),e},removeAll:function(){return n=n.filter((function(n){return n()})),e}};return e}function f(n){var e=n;function t(n){return e/=n,o}function r(n){return"number"==typeof n?n:n.get()}var o={add:function(n){return e+=r(n),o},divide:t,get:function(){return e},multiply:function(n){return e*=n,o},normalize:function(){return 0!==e&&t(e),o},set:function(n){return e=r(n),o},subtract:function(n){return e-=r(n),o}};return o}function l(n,e,o,i,a,u,c,s,l,p,g,m,v,h){var x=n.scroll,y=n.cross,b=["INPUT","SELECT","TEXTAREA"],w=f(0),M=f(0),S=f(0),E=d(),A=d(),T={mouse:2.5,touch:3.5},C={mouse:5,touch:7},D=a?5:12,P=!1,B=!1,I=!1,L=!1;function z(n){if(!(L="mousedown"===n.type)||0===n.button){var e,t,a=r(i.get(),c.get())>=2,s=L||!a,d=(e=n.target,t=e.nodeName||"",!(b.indexOf(t)>-1)),f=a||L&&d;P=!0,u.pointerDown(n),S.set(i),i.set(c),p.useBaseMass().useSpeed(80),function(){var n=L?document:o;A.add(n,"touchmove",O).add(n,"touchend",k).add(n,"mousemove",O).add(n,"mouseup",k)}(),w.set(u.readPoint(n,x)),M.set(u.readPoint(n,y)),h.emit("pointerDown"),s&&(I=!1),f&&n.preventDefault()}}function O(n){if(!B&&!L){if(!n.cancelable)return k();var t=u.readPoint(n,x).get(),o=u.readPoint(n,y).get(),a=r(t,w.get()),c=r(o,M.get());if(!(B=a>c)&&!I)return k()}var d=u.pointerMove(n);!I&&d&&(I=!0),s.start(),i.add(e.applyTo(d)),n.preventDefault()}function k(){var n=u.pointerUp()*(a?C:T)[L?"mouse":"touch"],o=function(n){var e=!(g.byDistance(0,!1).index!==m.get())&&Math.abs(n)>4,r=n+c.get();if(e&&!a&&!v.reachedAny(r)){var o=m.clone().add(-1*t(n));return g.byIndex(o.get(),0).distance}return g.byDistance(n,!a).distance}(e.applyTo(n)),s=function(n,e){if(0===n||0===e)return 0;if(Math.abs(n)<=Math.abs(e))return 0;var t=r(Math.abs(n),Math.abs(e));return Math.abs(t/n)}(n,o);r(i.get(),S.get())>=.5&&!L&&(I=!0),B=!1,P=!1,A.removeAll(),p.useSpeed(D+D*s),l.distance(o,!a),L=!1,h.emit("pointerUp")}function N(n){I&&n.preventDefault()}return{addActivationEvents:function(){var n=o;E.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",z).add(n,"mousedown",z).add(n,"touchcancel",k).add(n,"contextmenu",k).add(n,"click",N)},clickAllowed:function(){return!I},pointerDown:function(){return P},removeAllEvents:function(){E.removeAll(),A.removeAll()}}}function p(n,e){var t=Math.abs(n-e);function r(e){return e<n}function o(n){return n>e}function i(n){return r(n)||o(n)}return{constrain:function(t){return i(t)?r(t)?n:e:t},length:t,loop:function(t){return i(t)?r(t)?e:n:t},max:e,min:n,reachedAny:i,reachedMax:o,reachedMin:r,removeOffset:function(n){return t?n-t*Math.ceil((n-e)/t):n}}}function g(n,e,r){var o,i,a=(o=2,i=Math.pow(10,o),function(n){return Math.round(n*i)/i}),u=f(0),c=f(0),s=f(0),d=0,l=e,p=r;function g(n){return l=n,v}function m(n){return p=n,v}var v={direction:function(){return d},seek:function(e){s.set(e).subtract(n);var r,o,i,a=(r=s.get(),(i=0)+(r-(o=0))/(100-o)*(l-i));return d=t(s.get()),s.normalize().multiply(a).subtract(u),function(n){n.divide(p),c.add(n)}(s),v},settle:function(e){var t=e.get()-n.get(),r=!a(t);return r&&n.set(e),r},update:function(){u.add(c),n.add(u),c.multiply(0)},useBaseMass:function(){return m(r)},useBaseSpeed:function(){return g(e)},useMass:m,useSpeed:g};return v}function m(n,e,t){var r=!1;return{constrain:function(o,i){if(function(t){return!r&&(!!n.reachedAny(t.get())&&!!n.reachedAny(e.get()))}(o)){var a=i?.7:.4,u=o.get()-e.get();o.subtract(u*a),!i&&Math.abs(u)<10&&(o.set(n.constrain(o.get())),t.useSpeed(10).useMass(3))}},toggleActive:function(n){r=!n}}}function v(n,e,t,r,o){var i=p(-e+n,t[0]),u=r.map(i.constrain);return{snapsContained:function(){if(e<=n)return[i.max];if("keepSnaps"===o)return u;var t=function(){var n=u[0],e=a(u),t=u.lastIndexOf(n),r=u.indexOf(e)+1;return p(t,r)}(),r=t.min,c=t.max;return u.slice(r,c)}()}}function h(n,e,t,r){var o=p(t.min+e.measure(.1),t.max+e.measure(.1)),i=o.reachedMin,a=o.reachedMax;return{loop:function(e,t){if(function(n){return 1===n?a(r.get()):-1===n&&i(r.get())}(t)){var o=n*(-1*t);e.forEach((function(n){return n.add(o)}))}}}}function x(n){var e=n.max,t=n.length;return{get:function(n){return(n-e)/-t}}}function y(n,e,t,r,i,u){var c,s,d=n.startEdge,f=n.endEdge,l=i.map((function(n){return r[d]-n[d]})).map(t.measure).map((function(n){return-Math.abs(n)})),p=(c=o(l,u).map((function(n){return n[0]})),s=o(i,u).map((function(n){return a(n)[f]-n[0][d]})).map(t.measure).map(Math.abs).map(e.measure),c.map((function(n,e){return n+s[e]})));return{snaps:l,snapsAligned:p}}function b(n,e,t,r,o,i){var a=o.reachedMax,u=o.reachedAny,c=o.removeOffset;function s(n,e){return Math.abs(n)<Math.abs(e)?n:e}function d(n,t){var o=n,i=n+r,a=n-r;if(!e)return o;if(!t)return s(s(o,i),a);var u=s(o,1===t?i:a);return Math.abs(u)*t}return{byDistance:function(r,o){var s=i.get()+r,f=function(n){var e=c(n);return{index:t.map((function(n){return n-e})).map((function(n){return d(n,0)})).map((function(n,e){return{diff:n,index:e}})).sort((function(n,e){return Math.abs(n.diff)-Math.abs(e.diff)}))[0].index,distance:e}}(s),l=function(t,r){if(!(!e&&u(t)))return r;var o=n.min,i=n.max;return a(t)?o:i}(s,f.index),p=!e&&u(s);return!o||p?{index:l,distance:r}:{index:l,distance:r+d(t[l]-f.distance,0)}},byIndex:function(n,e){return{index:n,distance:d(t[n]-i.get(),e)}},shortcut:d}}function w(n,e,t,r,o,a,u){var c,s=i(r),d=i(r).reverse(),f=(c=o[0]-1,g(p(d,c),"end")).concat(function(){var n=e-o[0]-1;return g(p(s,n),"start")}());function l(n,e){return n.reduce((function(n,e){return n-r[e]}),e)}function p(n,e){return n.reduce((function(n,t){return l(n,e)>0?n.concat([t]):n}),[])}function g(n,e){var r="start"===e,o=r?-t:t,i=a.findSlideBounds(o);return n.map((function(n){var e=r?0:-t,o=r?t:0,a=i.filter((function(e){return e.index===n}))[0][r?"end":"start"];return{point:a,getTarget:function(){return u.get()>a?e:o},index:n,location:-1}}))}return{canLoop:function(){return f.every((function(n){var t=n.index;return l(s.filter((function(n){return n!==t})),e)<=0}))},clear:function(e){f.forEach((function(t){var r=t.index;e[r].style[n.startEdge]=""}))},loop:function(e){f.forEach((function(t){var r=t.getTarget,o=t.location,i=t.index,a=r();a!==o&&(e[i].style[n.startEdge]=a+"%",t.location=a)}))},loopPoints:f}}function M(n,e,t){var r=d(),o=r.removeAll,i=0;function a(n){9===n.keyCode&&(i=(new Date).getTime())}function u(o,a){r.add(o,"focus",(function(){if(!((new Date).getTime()-i>10)){n.scrollLeft=0;var r=Math.floor(a/t);e.index(r,0)}}),!0)}return{addActivationEvents:function(n){r.add(document,"keydown",a,!1),n.forEach(u)},removeAllEvents:o}}function S(n,e,t){var r=t.style,o="x"===n.scroll?function(n){return"translate3d("+n+"%,0px,0px)"}:function(n){return"translate3d(0px,"+n+"%,0px)"},i=!1;return{clear:function(){r.transform=""},to:function(n){i||(r.transform=o(e.applyTo(n.get())))},toggleActive:function(n){i=!n}}}function E(n,r,o,c,s){var d,E=c.align,A=c.axis,T=c.direction,C=c.startIndex,D=c.inViewThreshold,P=c.loop,B=c.speed,I=c.dragFree,L=c.slidesToScroll,z=c.containScroll,O=r.getBoundingClientRect(),k=o.map((function(n){return n.getBoundingClientRect()})),N=function(n){var e="rtl"===n?-1:1;return{applyTo:function(n){return n*e}}}(T),F=function(n,e){var t="y"===n?"y":"x";return{scroll:t,cross:"y"===n?"x":"y",startEdge:"y"===t?"top":"rtl"===e?"right":"left",endEdge:"y"===t?"bottom":"rtl"===e?"left":"right",measureSize:function(n){var e=n.width,r=n.height;return"x"===t?e:r}}}(A,T),U=(d=F.measureSize(O),{measure:function(n){return 0===d?0:n/d*100},totalPercent:100}),V=U.totalPercent,H=e(E,V),R=function(n,e,t,r,o){var i=n.measureSize,c=n.startEdge,s=n.endEdge,d=r.map(i);return{slideSizes:d.map(e.measure),slideSizesWithGaps:r.map((function(n,e,r){var i=e===u(r),f=window.getComputedStyle(a(t)),l=parseFloat(f.getPropertyValue("margin-"+s));return i?d[e]+(o?l:0):r[e+1][c]-n[c]})).map(e.measure).map(Math.abs)}}(F,U,o,k,P),j=R.slideSizes,G=R.slideSizesWithGaps,q=y(F,H,U,O,k,L),W=q.snaps,X=q.snapsAligned,J=-1*a(W)+a(G),Y=v(V,J,W,X,z).snapsContained,K=!P&&""!==z?Y:X,Q=function(n,e,t){var r,o;return{limit:(r=e[0],o=a(e),p(t?r-n:o,r))}}(J,K,P).limit,Z=function n(e,r,o){var i=e.min,a=e.max,u=e[r?"loop":"constrain"],c=u(o);function s(){return c}function d(n){return c=u(n),f}var f={add:function n(e){if(0!==e){var r=t(e);return d(s()+r),n(e+-1*r)}return f},clone:function(){return n(e,r,s())},get:s,max:a,min:i,set:d};return f}(p(0,u(K)),P,C),$=Z.clone(),_=i(o),nn=function(n){var e=0;function t(n,t){return function(){n===!!e&&t()}}function r(){e=window.requestAnimationFrame(n)}return{proceed:t(!0,r),start:t(!1,r),stop:t(!0,(function(){window.cancelAnimationFrame(e),e=0}))}}((function(){P||dn.scrollBounds.constrain(rn,dn.dragHandler.pointerDown()),dn.scrollBody.seek(rn).update();var n=dn.scrollBody.settle(rn);n&&!dn.dragHandler.pointerDown()&&(dn.animation.stop(),s.emit("settle")),n||s.emit("scroll"),P&&(dn.scrollLooper.loop(on,dn.scrollBody.direction()),dn.slideLooper.loop(o)),dn.translate.to(tn),dn.animation.proceed()})),en=K[Z.get()],tn=f(en),rn=f(en),on=[tn,rn],an=g(tn,B,1),un=b(Z,P,K,J,Q,rn),cn=function(n,e,t,r,o,i){function a(r){var a=r.distance,u=r.index!==e.get();a&&(n.start(),o.add(a)),u&&(t.set(e.get()),e.set(r.index),i.emit("select"))}return{distance:function(n,e){a(r.byDistance(n,e))},index:function(n,t){var o=e.clone().set(n);a(r.byIndex(o.get(),t))}}}(nn,Z,$,un,rn,s),sn=function(n,e,t,r,o,i){var a=Math.min(Math.max(i,.01),.99),u=(o?[0,e,-e]:[0]).reduce((function(n,e){return n.concat(c(e,a))}),[]);function c(e,o){var i=t.map((function(n){return n*(o||0)}));return r.map((function(r,o){return{start:r-t[o]+i[o]+e,end:r+n-i[o]+e,index:o}}))}return{check:function(n){return u.reduce((function(e,t){var r=t.index,o=t.start,i=t.end;return!(-1!==e.indexOf(r))&&(o<n&&i>n)?e.concat([r]):e}),[])},findSlideBounds:c}}(V,J,j,W,P,D),dn={animation:nn,axis:F,direction:N,dragHandler:l(F,N,n,rn,I,function(n,e){var t=n.scroll,r={x:"clientX",y:"clientY"},o=f(0),i=f(0),a=f(0),u=f(0),c=[],s=(new Date).getTime(),d=!1;function l(n,e){d=!n.touches;var t=r[e],o=d?n[t]:n.touches[0][t];return u.set(o)}return{pointerDown:function(n){var r=l(n,t);return o.set(r),a.set(r),e.measure(o.get())},pointerMove:function(n){var r=l(n,t),o=(new Date).getTime(),u=o-s;return u>=10&&(u>=100&&(c=[]),c.push(r.get()),s=o),i.set(r).subtract(a),a.set(r),e.measure(i.get())},pointerUp:function(){var n=(new Date).getTime()-s,t=a.get(),r=c.slice(-5).map((function(n){return t-n})).sort((function(n,e){return Math.abs(n)<Math.abs(e)?1:-1}))[0];return a.set(n>100||!r?0:r),c=[],e.measure(a.get())},readPoint:l}}(F,U),tn,nn,cn,an,un,Z,Q,s),pxToPercent:U,index:Z,indexPrevious:$,limit:Q,location:tn,options:c,scrollBody:an,scrollBounds:m(Q,tn,an),scrollLooper:h(J,U,Q,tn),scrollProgress:x(Q),scrollSnaps:K,scrollTarget:un,scrollTo:cn,slideFocus:M(n,cn,L),slideLooper:w(F,V,J,G,K,sn,tn),slidesInView:sn,slideIndexes:_,target:rn,translate:S(F,N,r)};return dn}var A={align:"center",axis:"x",containScroll:"",direction:"ltr",dragFree:!1,draggable:!0,draggableClass:"is-draggable",draggingClass:"is-dragging",inViewThreshold:0,loop:!1,selectedClass:"is-selected",slidesToScroll:1,speed:10,startIndex:0};return function(e,t){var r,o,i,a,u,f,l,p=function(){var n={};function e(e){return n[e]||[]}var t={emit:function(n){return e(n).forEach((function(e){return e(n)})),t},off:function(r,o){return n[r]=e(r).filter((function(n){return n!==o})),t},on:function(r,o){return n[r]=e(r).concat([o]),t}};return t}(),g=d(),m=(r=function(){if(y){var n=a.axis.measureSize(e.getBoundingClientRect());M!==n&&B(),p.emit("resize")}},o=500,i=0,function(){window.clearTimeout(i),i=window.setTimeout(r,o)||0}),v=B,h=p.on,x=p.off,y=!1,b=n({},A),w=n({},b),M=0;function S(){if(!e)throw new Error("Missing root node 😢");var n,t,r=e.querySelector("*");if(!r)throw new Error("Missing container node 😢");f=r,l=Array.prototype.slice.call(f.children),n=e,t=window.getComputedStyle(n,":before").content,u={get:function(){try{return JSON.parse(t.slice(1,-1).replace(/\\/g,""))}catch(n){}return{}}}}function T(t){if(S(),b=n({},b,t),w=n({},b,u.get()),a=E(e,f,l,w,p),g.add(window,"resize",m),a.translate.to(a.location),M=a.axis.measureSize(e.getBoundingClientRect()),w.loop){if(!a.slideLooper.canLoop())return P(),T({loop:!1});a.slideLooper.loop(l)}w.draggable&&f.offsetParent&&l.length&&(a.dragHandler.addActivationEvents(),w.draggableClass&&s(e,w.draggableClass),w.draggingClass&&p.on("pointerDown",C).on("pointerUp",C)),l.length&&a.slideFocus.addActivationEvents(l),w.selectedClass&&(D(),p.on("select",D).on("pointerUp",D)),y||(setTimeout((function(){return p.emit("init")}),0),y=!0)}function C(n){var t=w.draggingClass;"pointerDown"===n?s(e,t):c(e,t)}function D(){var n=w.selectedClass,e=I(!0);L(!0).forEach((function(e){return c(l[e],n)})),e.forEach((function(e){return s(l[e],n)}))}function P(){a.dragHandler.removeAllEvents(),a.slideFocus.removeAllEvents(),a.animation.stop(),g.removeAll(),a.translate.clear(),a.slideLooper.clear(l),c(e,w.draggableClass),l.forEach((function(n){return c(n,w.selectedClass)})),p.off("select",D).off("pointerUp",D).off("pointerDown",C).off("pointerUp",C)}function B(e){if(y){var t=n({startIndex:O()},e);P(),T(t),p.emit("reInit")}}function I(n){var e=a[n?"target":"location"].get(),t=w.loop?"removeOffset":"constrain";return a.slidesInView.check(a.limit[t](e))}function L(n){var e=I(n);return a.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}function z(n,e){a.scrollBody.useBaseMass().useBaseSpeed(),y&&a.scrollTo.index(n,e||0)}function O(){return a.index.get()}return T(t),{canScrollNext:function(){return a.index.clone().add(1).get()!==O()},canScrollPrev:function(){return a.index.clone().add(-1).get()!==O()},clickAllowed:function(){return a.dragHandler.clickAllowed()},containerNode:function(){return f},dangerouslyGetEngine:function(){return a},destroy:function(){y&&(P(),y=!1,p.emit("destroy"))},off:x,on:h,previousScrollSnap:function(){return a.indexPrevious.get()},reInit:v,rootNode:function(){return e},scrollNext:function(){z(a.index.clone().add(1).get(),-1)},scrollPrev:function(){z(a.index.clone().add(-1).get(),1)},scrollProgress:function(){return a.scrollProgress.get(a.location.get())},scrollSnapList:function(){return a.scrollSnaps.map(a.scrollProgress.get)},scrollTo:z,selectedScrollSnap:O,slideNodes:function(){return l},slidesInView:I,slidesNotInView:L}}}));
{
"name": "embla-carousel",
"version": "4.3.0",
"version": "4.3.1",
"private": false,

@@ -5,0 +5,0 @@ "author": "David Cetinkaya <david.o.cetinkaya@gmail.com>",

@@ -532,13 +532,4 @@ import { useState, useRef, useMemo, useEffect } from 'react';

function removeOffset(n) {
if (min === max) return n;
while (reachedMin(n)) {
n += length;
}
while (reachedMax(n)) {
n -= length;
}
return n;
if (!length) return n;
return n - length * Math.ceil((n - max) / length);
}

@@ -1287,7 +1278,7 @@

function OptionsPseudo(node) {
var psuedoString = window.getComputedStyle(node, ':before').content;
var pseudoString = window.getComputedStyle(node, ':before').content;
function get() {
try {
return JSON.parse(psuedoString.slice(1, -1).replace(/\\/g, ''));
return JSON.parse(pseudoString.slice(1, -1).replace(/\\/g, ''));
} catch (error) {} // eslint-disable-line no-empty

@@ -1350,4 +1341,6 @@

var options = _extends({}, defaultOptions);
var optionsBase = _extends({}, defaultOptions);
var options = _extends({}, optionsBase);
var optionsPseudo;

@@ -1370,3 +1363,4 @@ var rootNodeSize = 0;

setupElements();
options = _extends(options, partialOptions, optionsPseudo.get());
optionsBase = _extends({}, optionsBase, partialOptions);
options = _extends({}, optionsBase, optionsPseudo.get());
engine = Engine(sliderRoot, container, slides, options, events);

@@ -1445,6 +1439,3 @@ eventStore.add(window, 'resize', debouncedResize);

});
events.off('select', toggleSelectedClass);
events.off('pointerUp', toggleSelectedClass);
events.off('pointerDown', toggleDraggingClass);
events.off('pointerUp', toggleDraggingClass);
events.off('select', toggleSelectedClass).off('pointerUp', toggleSelectedClass).off('pointerDown', toggleDraggingClass).off('pointerUp', toggleDraggingClass);
}

@@ -1451,0 +1442,0 @@

@@ -536,13 +536,4 @@ 'use strict';

function removeOffset(n) {
if (min === max) return n;
while (reachedMin(n)) {
n += length;
}
while (reachedMax(n)) {
n -= length;
}
return n;
if (!length) return n;
return n - length * Math.ceil((n - max) / length);
}

@@ -1291,7 +1282,7 @@

function OptionsPseudo(node) {
var psuedoString = window.getComputedStyle(node, ':before').content;
var pseudoString = window.getComputedStyle(node, ':before').content;
function get() {
try {
return JSON.parse(psuedoString.slice(1, -1).replace(/\\/g, ''));
return JSON.parse(pseudoString.slice(1, -1).replace(/\\/g, ''));
} catch (error) {} // eslint-disable-line no-empty

@@ -1354,4 +1345,6 @@

var options = _extends({}, defaultOptions);
var optionsBase = _extends({}, defaultOptions);
var options = _extends({}, optionsBase);
var optionsPseudo;

@@ -1374,3 +1367,4 @@ var rootNodeSize = 0;

setupElements();
options = _extends(options, partialOptions, optionsPseudo.get());
optionsBase = _extends({}, optionsBase, partialOptions);
options = _extends({}, optionsBase, optionsPseudo.get());
engine = Engine(sliderRoot, container, slides, options, events);

@@ -1449,6 +1443,3 @@ eventStore.add(window, 'resize', debouncedResize);

});
events.off('select', toggleSelectedClass);
events.off('pointerUp', toggleSelectedClass);
events.off('pointerDown', toggleDraggingClass);
events.off('pointerUp', toggleDraggingClass);
events.off('select', toggleSelectedClass).off('pointerUp', toggleSelectedClass).off('pointerDown', toggleDraggingClass).off('pointerUp', toggleDraggingClass);
}

@@ -1455,0 +1446,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc