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.2.0 to 4.2.1

12

embla-carousel.esm.js

@@ -1127,5 +1127,3 @@ function _extends() {

var translate = axis.scroll === 'x' ? x : y;
var roundToTwoDecimals = roundToDecimals(2);
var disabled = false;
var location = 0;

@@ -1140,8 +1138,5 @@ function x(n) {

function to(v) {
var target = roundToTwoDecimals(v.get());
if (disabled || location === target) return;
getComputedStyle(container).transform;
containerStyle.transform = translate(direction.applyTo(target));
location = target;
function to(target) {
if (disabled) return;
containerStyle.transform = translate(direction.applyTo(target.get()));
}

@@ -1155,3 +1150,2 @@

containerStyle.transform = '';
location = 0;
}

@@ -1158,0 +1152,0 @@

@@ -1129,5 +1129,3 @@ 'use strict';

var translate = axis.scroll === 'x' ? x : y;
var roundToTwoDecimals = roundToDecimals(2);
var disabled = false;
var location = 0;

@@ -1142,8 +1140,5 @@ function x(n) {

function to(v) {
var target = roundToTwoDecimals(v.get());
if (disabled || location === target) return;
getComputedStyle(container).transform;
containerStyle.transform = translate(direction.applyTo(target));
location = target;
function to(target) {
if (disabled) return;
containerStyle.transform = translate(direction.applyTo(target.get()));
}

@@ -1157,3 +1152,2 @@

containerStyle.transform = '';
location = 0;
}

@@ -1160,0 +1154,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=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){var e=Math.pow(10,n);return function(n){return Math.round(n*e)/e}}function i(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function u(n){return Object.keys(n).map(Number)}function a(n){return n[c(n)]}function c(n){return Math.max(0,n.length-1)}function s(n,e){var t=n.classList;e&&t.contains(e)&&t.remove(e)}function f(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 l(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 p(n,e,o,i,u,a,c,s,f,p,g,m,v,h){var x=n.scroll,y=n.cross,b=["INPUT","SELECT","TEXTAREA"],w=l(0),M=l(0),S=l(0),E=d(),A=d(),T={mouse:2.5,touch:3.5},C={mouse:5,touch:7},D=u?5:12,P=!1,B=!1,z=!1,I=!1;function L(n){if(!(I="mousedown"===n.type)||0===n.button){var e,t,u=r(i.get(),c.get())>=2,s=I||!u,f=(e=n.target,t=e.nodeName||"",!(b.indexOf(t)>-1)),d=u||I&&f;P=!0,a.pointerDown(n),S.set(i),i.set(c),p.useBaseMass().useSpeed(80),function(){var n=I?document:o;A.add(n,"touchmove",k).add(n,"touchend",O).add(n,"mousemove",k).add(n,"mouseup",O)}(),w.set(a.readPoint(n,x)),M.set(a.readPoint(n,y)),h.emit("pointerDown"),s&&(z=!1),d&&n.preventDefault()}}function k(n){if(!B&&!I){if(!n.cancelable)return O();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)&&!z)return O()}var f=a.pointerMove(n);!z&&f&&(z=!0),s.start(),i.add(e.applyTo(f)),n.preventDefault()}function O(){var n=a.pointerUp()*(u?C:T)[I?"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&&!I&&(z=!0),B=!1,P=!1,A.removeAll(),p.useSpeed(D+D*s),f.distance(o,!u),I=!1,h.emit("pointerUp")}function N(n){z&&n.preventDefault()}return{addActivationEvents:function(){var n=o;E.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",L).add(n,"mousedown",L).add(n,"touchcancel",O).add(n,"contextmenu",O).add(n,"click",N)},clickAllowed:function(){return!z},pointerDown:function(){return P},removeAllEvents:function(){E.removeAll(),A.removeAll()}}}function g(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 m(n,e,r){var i=o(2),u=l(0),a=l(0),c=l(0),s=0,f=e,d=r;function p(n){return f=n,m}function g(n){return d=n,m}var m={direction:function(){return s},seek:function(e){c.set(e).subtract(n);var r,o,i,l=(r=c.get(),(i=0)+(r-(o=0))/(100-o)*(f-i));return s=t(c.get()),c.normalize().multiply(l).subtract(u),function(n){n.divide(d),a.add(n)}(c),m},settle:function(e){var t=e.get()-n.get(),r=!i(t);return r&&n.set(e),r},update:function(){u.add(a),n.add(u),a.multiply(0)},useBaseMass:function(){return g(r)},useBaseSpeed:function(){return p(e)},useMass:g,useSpeed:p};return m}function v(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 h(n,e,t,r,o){var i=g(-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 g(t,r)}(),r=t.min,c=t.max;return u.slice(r,c)}()}}function x(n,e,t,r){var o=g(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 y(n){var e=n.max,t=n.length;return{get:function(n){return(n-e)/-t}}}function b(n,e,t,r,o,u){var c,s,f=n.startEdge,d=n.endEdge,l=o.map((function(n){return r[f]-n[f]})).map(t.measure).map((function(n){return-Math.abs(n)})),p=(c=i(l,u).map((function(n){return n[0]})),s=i(o,u).map((function(n){return a(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 w(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 M(n,e,t,r,o,i,a){var c,s=u(r),f=u(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,u=i.findSlideBounds(o);return n.map((function(n){var e=r?0:-t,o=r?t:0,i=u.filter((function(e){return e.index===n}))[0][r?"end":"start"];return{point:i,getTarget:function(){return a.get()>i?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 S(n,e,t){var r=d(),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 E(n,e,t){var r=t.style,i="x"===n.scroll?function(n){return"translate3d("+n+"%,0px,0px)"}:function(n){return"translate3d(0px,"+n+"%,0px)"},u=o(2),a=!1,c=0;return{clear:function(){r.transform="",c=0},to:function(n){var o=u(n.get());a||c===o||(getComputedStyle(t).transform,r.transform=i(e.applyTo(o)),c=o)},toggleActive:function(n){a=!n}}}function A(n,r,o,i,s){var f,d=i.align,A=i.axis,T=i.direction,C=i.startIndex,D=i.inViewThreshold,P=i.loop,B=i.speed,z=i.dragFree,I=i.slidesToScroll,L=i.containScroll,k=r.getBoundingClientRect(),O=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),R=(f=F.measureSize(k),{measure:function(n){return 0===f?0:n/f*100},totalPercent:100}),U=R.totalPercent,V=e(d,U),H=function(n,e,t,r,o){var i=n.measureSize,u=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===c(r),d=window.getComputedStyle(a(t)),l=parseFloat(d.getPropertyValue("margin-"+s));return i?f[e]+(o?l:0):r[e+1][u]-n[u]})).map(e.measure).map(Math.abs)}}(F,R,o,O,P),j=H.slideSizes,G=H.slideSizesWithGaps,q=b(F,V,R,k,O,I),W=q.snaps,X=q.snapsAligned,Y=-1*a(W)+a(G),J=h(U,Y,W,X,L).snapsContained,K=!P&&""!==L?J:X,Q=function(n,e,t){var r,o;return{limit:(r=e[0],o=a(e),g(t?r-n:o,r))}}(Y,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}(g(0,c(K)),P,C),$=Z.clone(),_=u(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=l(en),rn=l(en),on=[tn,rn],un=m(tn,B,1),an=w(Z,P,K,Y,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}}(U,Y,j,W,P,D),fn={animation:nn,axis:F,direction:N,dragHandler:p(F,N,n,rn,z,function(n,e){var t=n.scroll,r={x:"clientX",y:"clientY"},o=l(0),i=l(0),u=l(0),a=l(0),c=[],s=(new Date).getTime(),f=!1;function d(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=d(n,t);return o.set(r),u.set(r),e.measure(o.get())},pointerMove:function(n){var r=d(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:d}}(F,R),tn,nn,cn,un,an,Z,Q,s),pxToPercent:R,index:Z,indexPrevious:$,limit:Q,location:tn,options:i,scrollBody:un,scrollBounds:v(Q,tn,un),scrollLooper:x(Y,R,Q,tn),scrollProgress:y(Q),scrollSnaps:K,scrollTarget:an,scrollTo:cn,slideFocus:S(n,cn,I),slideLooper:M(F,U,Y,G,K,sn,tn),slidesInView:sn,slideIndexes:_,target:rn,translate:E(F,N,r)};return fn}var T={align:"center",autoResize:!0,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,c,l=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}(),p=d(),g=(r=function(){if(x){if(y.autoResize){var n=u.axis.measureSize(e.getBoundingClientRect());b!==n&&C()}l.emit("resize")}},o=500,i=0,function(){window.clearTimeout(i),i=window.setTimeout(r,o)||0}),m=C,v=l.on,h=l.off,x=!1,y=n({},T),b=0;function w(t){if(function(){if(!e)throw new Error("Missing root node 😢");var n=e.querySelector("*");if(!n)throw new Error("Missing container node 😢");a=n,c=Array.prototype.slice.call(a.children)}(),y=n(y,t),u=A(e,a,c,y,l),p.add(window,"resize",g),u.translate.to(u.location),y.autoResize&&(b=u.axis.measureSize(e.getBoundingClientRect())),y.loop){if(!u.slideLooper.canLoop())return E(),w({loop:!1});u.slideLooper.loop(c)}y.draggable&&a.offsetParent&&c.length&&(u.dragHandler.addActivationEvents(),y.draggableClass&&f(e,y.draggableClass),y.draggingClass&&l.on("pointerDown",M).on("pointerUp",M)),c.length&&u.slideFocus.addActivationEvents(c),y.selectedClass&&(S(),l.on("select",S).on("pointerUp",S)),x||(setTimeout((function(){return l.emit("init")}),0),x=!0)}function M(n){var t=y.draggingClass;"pointerDown"===n?f(e,t):s(e,t)}function S(){var n=y.selectedClass,e=D(!0);P(!0).forEach((function(e){return s(c[e],n)})),e.forEach((function(e){return f(c[e],n)}))}function E(){u.dragHandler.removeAllEvents(),u.slideFocus.removeAllEvents(),u.animation.stop(),p.removeAll(),u.translate.clear(),u.slideLooper.clear(c),s(e,y.draggableClass),c.forEach((function(n){return s(n,y.selectedClass)})),l.off("select",S),l.off("pointerUp",S),l.off("pointerDown",M),l.off("pointerUp",M)}function C(e){if(x){var t=n({startIndex:z()},e);E(),w(t),l.emit("reInit")}}function D(n){var e=u[n?"target":"location"].get(),t=y.loop?"removeOffset":"constrain";return u.slidesInView.check(u.limit[t](e))}function P(n){var e=D(n);return u.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}function B(n,e){u.scrollBody.useBaseMass().useBaseSpeed(),x&&u.scrollTo.index(n,e||0)}function z(){return u.index.get()}return w(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 a},dangerouslyGetEngine:function(){return u},destroy:function(){x&&(E(),x=!1,l.emit("destroy"))},off:h,on:v,previousScrollSnap:function(){return u.indexPrevious.get()},reInit:m,rootNode:function(){return e},scrollNext:function(){B(u.index.clone().add(1).get(),-1)},scrollPrev:function(){B(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:B,selectedScrollSnap:z,slideNodes:function(){return c},slidesInView:D,slidesNotInView:P}}}));
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n=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),E=d(0),S=f(),A=f(),T={mouse:2.5,touch:3.5},C={mouse:5,touch:7},D=u?5:12,P=!1,B=!1,z=!1,I=!1;function L(n){if(!(I="mousedown"===n.type)||0===n.button){var e,t,u=r(i.get(),c.get())>=2,s=I||!u,f=(e=n.target,t=e.nodeName||"",!(b.indexOf(t)>-1)),d=u||I&&f;P=!0,a.pointerDown(n),E.set(i),i.set(c),p.useBaseMass().useSpeed(80),function(){var n=I?document:o;A.add(n,"touchmove",k).add(n,"touchend",O).add(n,"mousemove",k).add(n,"mouseup",O)}(),w.set(a.readPoint(n,x)),M.set(a.readPoint(n,y)),h.emit("pointerDown"),s&&(z=!1),d&&n.preventDefault()}}function k(n){if(!B&&!I){if(!n.cancelable)return O();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)&&!z)return O()}var f=a.pointerMove(n);!z&&f&&(z=!0),s.start(),i.add(e.applyTo(f)),n.preventDefault()}function O(){var n=a.pointerUp()*(u?C:T)[I?"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(),E.get())>=.5&&!I&&(z=!0),B=!1,P=!1,A.removeAll(),p.useSpeed(D+D*s),l.distance(o,!u),I=!1,h.emit("pointerUp")}function N(n){z&&n.preventDefault()}return{addActivationEvents:function(){var n=o;S.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",L).add(n,"mousedown",L).add(n,"touchcancel",O).add(n,"contextmenu",O).add(n,"click",N)},clickAllowed:function(){return!z},pointerDown:function(){return P},removeAllEvents:function(){S.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 E(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 S(n,r,o,c,s){var f,S=c.align,A=c.axis,T=c.direction,C=c.startIndex,D=c.inViewThreshold,P=c.loop,B=c.speed,z=c.dragFree,I=c.slidesToScroll,L=c.containScroll,k=r.getBoundingClientRect(),O=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),R=(f=F.measureSize(k),{measure:function(n){return 0===f?0:n/f*100},totalPercent:100}),U=R.totalPercent,V=e(S,U),H=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,R,o,O,P),j=H.slideSizes,G=H.slideSizesWithGaps,q=y(F,V,R,k,O,I),W=q.snaps,X=q.snapsAligned,Y=-1*u(W)+u(G),J=v(U,Y,W,X,L).snapsContained,K=!P&&""!==L?J:X,Q=function(n,e,t){var r,o;return{limit:(r=e[0],o=u(e),p(t?r-n:o,r))}}(Y,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,Y,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}}(U,Y,j,W,P,D),fn={animation:nn,axis:F,direction:N,dragHandler:l(F,N,n,rn,z,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,R),tn,nn,cn,un,an,Z,Q,s),pxToPercent:R,index:Z,indexPrevious:$,limit:Q,location:tn,options:c,scrollBody:un,scrollBounds:m(Q,tn,un),scrollLooper:h(Y,R,Q,tn),scrollProgress:x(Q),scrollSnaps:K,scrollTarget:an,scrollTo:cn,slideFocus:M(n,cn,I),slideLooper:w(F,U,Y,G,K,sn,tn),slidesInView:sn,slideIndexes:_,target:rn,translate:E(F,N,r)};return fn}var A={align:"center",autoResize:!0,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=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}(),p=f(),g=(r=function(){if(x){if(y.autoResize){var n=u.axis.measureSize(e.getBoundingClientRect());b!==n&&C()}l.emit("resize")}},o=500,i=0,function(){window.clearTimeout(i),i=window.setTimeout(r,o)||0}),m=C,v=l.on,h=l.off,x=!1,y=n({},A),b=0;function w(t){if(function(){if(!e)throw new Error("Missing root node 😢");var n=e.querySelector("*");if(!n)throw new Error("Missing container node 😢");a=n,d=Array.prototype.slice.call(a.children)}(),y=n(y,t),u=S(e,a,d,y,l),p.add(window,"resize",g),u.translate.to(u.location),y.autoResize&&(b=u.axis.measureSize(e.getBoundingClientRect())),y.loop){if(!u.slideLooper.canLoop())return T(),w({loop:!1});u.slideLooper.loop(d)}y.draggable&&a.offsetParent&&d.length&&(u.dragHandler.addActivationEvents(),y.draggableClass&&s(e,y.draggableClass),y.draggingClass&&l.on("pointerDown",M).on("pointerUp",M)),d.length&&u.slideFocus.addActivationEvents(d),y.selectedClass&&(E(),l.on("select",E).on("pointerUp",E)),x||(setTimeout((function(){return l.emit("init")}),0),x=!0)}function M(n){var t=y.draggingClass;"pointerDown"===n?s(e,t):c(e,t)}function E(){var n=y.selectedClass,e=D(!0);P(!0).forEach((function(e){return c(d[e],n)})),e.forEach((function(e){return s(d[e],n)}))}function T(){u.dragHandler.removeAllEvents(),u.slideFocus.removeAllEvents(),u.animation.stop(),p.removeAll(),u.translate.clear(),u.slideLooper.clear(d),c(e,y.draggableClass),d.forEach((function(n){return c(n,y.selectedClass)})),l.off("select",E),l.off("pointerUp",E),l.off("pointerDown",M),l.off("pointerUp",M)}function C(e){if(x){var t=n({startIndex:z()},e);T(),w(t),l.emit("reInit")}}function D(n){var e=u[n?"target":"location"].get(),t=y.loop?"removeOffset":"constrain";return u.slidesInView.check(u.limit[t](e))}function P(n){var e=D(n);return u.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}function B(n,e){u.scrollBody.useBaseMass().useBaseSpeed(),x&&u.scrollTo.index(n,e||0)}function z(){return u.index.get()}return w(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 a},dangerouslyGetEngine:function(){return u},destroy:function(){x&&(T(),x=!1,l.emit("destroy"))},off:h,on:v,previousScrollSnap:function(){return u.indexPrevious.get()},reInit:m,rootNode:function(){return e},scrollNext:function(){B(u.index.clone().add(1).get(),-1)},scrollPrev:function(){B(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:B,selectedScrollSnap:z,slideNodes:function(){return d},slidesInView:D,slidesNotInView:P}}}));
{
"name": "embla-carousel",
"version": "4.2.0",
"version": "4.2.1",
"private": false,

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

@@ -1129,5 +1129,3 @@ import { useState, useRef, useMemo, useEffect } from 'react';

var translate = axis.scroll === 'x' ? x : y;
var roundToTwoDecimals = roundToDecimals(2);
var disabled = false;
var location = 0;

@@ -1142,8 +1140,5 @@ function x(n) {

function to(v) {
var target = roundToTwoDecimals(v.get());
if (disabled || location === target) return;
getComputedStyle(container).transform;
containerStyle.transform = translate(direction.applyTo(target));
location = target;
function to(target) {
if (disabled) return;
containerStyle.transform = translate(direction.applyTo(target.get()));
}

@@ -1157,3 +1152,2 @@

containerStyle.transform = '';
location = 0;
}

@@ -1160,0 +1154,0 @@

@@ -1133,5 +1133,3 @@ 'use strict';

var translate = axis.scroll === 'x' ? x : y;
var roundToTwoDecimals = roundToDecimals(2);
var disabled = false;
var location = 0;

@@ -1146,8 +1144,5 @@ function x(n) {

function to(v) {
var target = roundToTwoDecimals(v.get());
if (disabled || location === target) return;
getComputedStyle(container).transform;
containerStyle.transform = translate(direction.applyTo(target));
location = target;
function to(target) {
if (disabled) return;
containerStyle.transform = translate(direction.applyTo(target.get()));
}

@@ -1161,3 +1156,2 @@

containerStyle.transform = '';
location = 0;
}

@@ -1164,0 +1158,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