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.1.1 to 4.1.2

53

embla-carousel.esm.js

@@ -407,7 +407,5 @@ function _extends() {

var diff = dragTracker.pointerMove(evt);
var reachedLimit = limit.reachedAny(location.get());
var resist = !params.loop && reachedLimit ? 4 : 1;
if (!preventClick && diff) preventClick = true;
animation.start();
target.add(direction.applyTo(diff / resist));
target.add(direction.applyTo(diff));
evt.preventDefault();

@@ -672,32 +670,22 @@ }

location = params.location,
scrollBody = params.scrollBody,
animation = params.animation;
var min = limit.min,
max = limit.max;
var tolerance = 70;
var edgeLimit = Limit({
min: min - tolerance,
max: max + tolerance
});
scrollBody = params.scrollBody;
var pullBackThreshold = 10;
var disabled = false;
var timeout = 0;
function shouldConstrain(target) {
if (disabled) return false;
if (!limit.reachedAny(target.get())) return false;
if (!limit.reachedAny(location.get())) return false;
if (target.get() === min || target.get() === max) return false;
return true;
}
function constrain(target) {
function constrain(target, pointerDown) {
if (!shouldConstrain(target)) return;
target.set(edgeLimit.constrain(target.get()));
var friction = pointerDown ? 0.7 : 0.4;
var diffToTarget = target.get() - location.get();
target.subtract(diffToTarget * friction);
if (!timeout) {
timeout = window.setTimeout(function () {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
animation.start();
timeout = 0;
}, tolerance);
if (!pointerDown && Math.abs(diffToTarget) < pullBackThreshold) {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
}

@@ -1296,12 +1284,16 @@ }

var update = function update() {
if (!loop) {
engine.scrollBounds.constrain(target, engine.dragHandler.pointerDown());
}
engine.scrollBody.seek(target).update();
var settled = engine.scrollBody.settle(target);
if (!engine.dragHandler.pointerDown()) {
if (!loop) engine.scrollBounds.constrain(target);
if (settled && !engine.dragHandler.pointerDown()) {
engine.animation.stop();
events.emit('settle');
}
if (settled) {
engine.animation.stop();
events.emit('settle');
}
if (!settled) {
events.emit('scroll');
}

@@ -1314,3 +1306,2 @@

if (!settled) events.emit('scroll');
engine.translate.to(location);

@@ -1369,3 +1360,2 @@ engine.animation.proceed();

location: location,
loop: loop,
scrollBody: scrollBody,

@@ -1390,3 +1380,2 @@ scrollTo: scrollTo,

scrollBounds: ScrollBounds({
animation: animation,
limit: limit,

@@ -1393,0 +1382,0 @@ location: location,

@@ -409,7 +409,5 @@ 'use strict';

var diff = dragTracker.pointerMove(evt);
var reachedLimit = limit.reachedAny(location.get());
var resist = !params.loop && reachedLimit ? 4 : 1;
if (!preventClick && diff) preventClick = true;
animation.start();
target.add(direction.applyTo(diff / resist));
target.add(direction.applyTo(diff));
evt.preventDefault();

@@ -674,32 +672,22 @@ }

location = params.location,
scrollBody = params.scrollBody,
animation = params.animation;
var min = limit.min,
max = limit.max;
var tolerance = 70;
var edgeLimit = Limit({
min: min - tolerance,
max: max + tolerance
});
scrollBody = params.scrollBody;
var pullBackThreshold = 10;
var disabled = false;
var timeout = 0;
function shouldConstrain(target) {
if (disabled) return false;
if (!limit.reachedAny(target.get())) return false;
if (!limit.reachedAny(location.get())) return false;
if (target.get() === min || target.get() === max) return false;
return true;
}
function constrain(target) {
function constrain(target, pointerDown) {
if (!shouldConstrain(target)) return;
target.set(edgeLimit.constrain(target.get()));
var friction = pointerDown ? 0.7 : 0.4;
var diffToTarget = target.get() - location.get();
target.subtract(diffToTarget * friction);
if (!timeout) {
timeout = window.setTimeout(function () {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
animation.start();
timeout = 0;
}, tolerance);
if (!pointerDown && Math.abs(diffToTarget) < pullBackThreshold) {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
}

@@ -1298,12 +1286,16 @@ }

var update = function update() {
if (!loop) {
engine.scrollBounds.constrain(target, engine.dragHandler.pointerDown());
}
engine.scrollBody.seek(target).update();
var settled = engine.scrollBody.settle(target);
if (!engine.dragHandler.pointerDown()) {
if (!loop) engine.scrollBounds.constrain(target);
if (settled && !engine.dragHandler.pointerDown()) {
engine.animation.stop();
events.emit('settle');
}
if (settled) {
engine.animation.stop();
events.emit('settle');
}
if (!settled) {
events.emit('scroll');
}

@@ -1316,3 +1308,2 @@

if (!settled) events.emit('scroll');
engine.translate.to(location);

@@ -1371,3 +1362,2 @@ engine.animation.proceed();

location: location,
loop: loop,
scrollBody: scrollBody,

@@ -1392,3 +1382,2 @@ scrollTo: scrollTo,

scrollBounds: ScrollBounds({
animation: animation,
limit: limit,

@@ -1395,0 +1384,0 @@ location: location,

@@ -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){var e=n.viewSize,t=n.align,r={start:function(){return 0},center:function(n){return o(n)/2},end:o};function o(n){return e-n}return{measure:function(n){return"number"==typeof t?e*Number(t):r[t](n)}}}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){return Object.keys(n).map(Number)}function a(n,e){var t=n.classList;e&&t.contains(e)&&t.remove(e)}function c(n,e){var t=n.classList;e&&!t.contains(e)&&t.add(e)}function u(n){var e=n.start,r=n.limit,o=n.loop,i=r.min,a=r.max,c=r[o?"loop":"constrain"],s=c(e);function l(){return s}function d(n){return s=c(n),f}var f={add:function n(e){if(0!==e){var r=t(e);return d(l()+r),n(e+-1*r)}return f},clone:function(){return u({start:l(),limit:r,loop:o})},get:l,max:a,min:i,set:d};return f}function s(){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 d(n){var e=n.target,o=n.scrollBody,i=n.dragFree,a=n.animation,c=n.axis,u=n.scrollTo,d=n.root,f=n.dragTracker,m=n.location,p=n.events,g=n.limit,v=n.direction,x=c.scroll,h=c.cross,S=["INPUT","SELECT","TEXTAREA"],y=l(0),w=l(0),T=l(0),b=s(),M=s(),z={mouse:2.5,touch:3.5},A={mouse:5,touch:7},E=i?5:12,P=!1,D=!1,B=!1,I=!1;function C(n){if(!(I="mousedown"===n.type)||0===n.button){var t,i,a=r(e.get(),m.get())>=2,c=I||!a,u=(t=n.target,i=t.nodeName||"",!(S.indexOf(i)>-1)),s=a||I&&u;P=!0,f.pointerDown(n),T.set(e),e.set(m),o.useBaseMass().useSpeed(80),function(){var n=I?document:d;M.add(n,"touchmove",L).add(n,"touchend",k).add(n,"mousemove",L).add(n,"mouseup",k)}(),y.set(f.readPoint(n,x)),w.set(f.readPoint(n,h)),p.emit("pointerDown"),c&&(B=!1),s&&n.preventDefault()}}function L(t){if(!D&&!I){if(!t.cancelable)return k();var o=f.readPoint(t,x).get(),i=f.readPoint(t,h).get(),c=r(o,y.get()),u=r(i,w.get());if(!(D=c>u)&&!B)return k()}var s=f.pointerMove(t),l=g.reachedAny(m.get()),d=!n.loop&&l?4:1;!B&&s&&(B=!0),a.start(),e.add(v.applyTo(s/d)),t.preventDefault()}function k(){var a=f.pointerUp()*(i?A:z)[I?"mouse":"touch"],c=function(e){var r=n.scrollTarget,o=n.index,a=!(r.byDistance(0,!1).index!==o.get())&&Math.abs(e)>4,c=e+m.get();if(a&&!i&&!g.reachedAny(c)){var u=o.clone().add(-1*t(e));return r.byIndex(u.get(),0).distance}return r.byDistance(e,!i).distance}(v.applyTo(a)),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)}(a,c);r(e.get(),T.get())>=.5&&!I&&(B=!0),D=!1,P=!1,M.removeAll(),o.useSpeed(E+E*s),u.distance(c,!i),I=!1,p.emit("pointerUp")}function O(n){B&&n.preventDefault()}return{addActivationEvents:function(){var n=d;b.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",C).add(n,"mousedown",C).add(n,"touchcancel",k).add(n,"contextmenu",k).add(n,"click",O)},clickAllowed:function(){return!B},pointerDown:function(){return P},removeAllEvents:function(){b.removeAll(),M.removeAll()}}}function f(n){var e=n.axis,t=n.pxToPercent,r=e.scroll,o={x:"clientX",y:"clientY"},i=l(0),a=l(0),c=l(0),u=l(0),s=[],d=(new Date).getTime(),f=!1;function m(n,e){f=!n.touches;var t=o[e],r=f?n[t]:n.touches[0][t];return u.set(r)}return{pointerDown:function(n){var e=m(n,r);return i.set(e),c.set(e),t.measure(i.get())},pointerMove:function(n){var e=m(n,r),o=(new Date).getTime(),i=o-d;return i>=10&&(i>=100&&(s=[]),s.push(e.get()),d=o),a.set(e).subtract(c),c.set(e),t.measure(a.get())},pointerUp:function(){var n=(new Date).getTime()-d,e=c.get(),r=s.slice(-5).map((function(n){return e-n})).sort((function(n,e){return Math.abs(n)<Math.abs(e)?1:-1}))[0];return c.set(n>100||!r?0:r),s=[],t.measure(c.get())},readPoint:m}}function m(n){var e=n.min,t=n.max,r=Math.abs(e-t);function o(n){return n<e}function i(n){return n>t}function a(n){return o(n)||i(n)}return{constrain:function(n){return a(n)?o(n)?e:t:n},length:r,loop:function(n){return a(n)?o(n)?t:e:n},max:t,min:e,reachedAny:a,reachedMax:i,reachedMin:o,removeOffset:function(n){if(e===t)return n;for(;o(n);)n+=r;for(;i(n);)n-=r;return n}}}function p(n){var e=n.location,r=n.speed,i=n.mass,a=o(2),c=l(0),u=l(0),s=l(0),d=0,f=r,m=i;function p(n){return f=n,v}function g(n){return m=n,v}var v={direction:function(){return d},seek:function(n){s.set(n).subtract(e);var r,o,i=s.get(),a=(o=0)+(i-(r=0))/(100-r)*(f-o);return d=t(s.get()),s.normalize().multiply(a).subtract(c),function(n){n.divide(m),u.add(n)}(s),v},settle:function(n){var t=n.get()-e.get(),r=!a(t);return r&&e.set(n),r},update:function(){c.add(u),e.add(c),u.multiply(0)},useBaseMass:function(){return g(i)},useBaseSpeed:function(){return p(r)},useMass:g,useSpeed:p};return v}function g(n){var e=n.limit,t=n.location,r=n.scrollBody,o=n.animation,i=e.min,a=e.max,c=m({min:i-70,max:a+70}),u=!1,s=0;return{constrain:function(n){(function(n){return!u&&(!!e.reachedAny(t.get())&&(n.get()!==i&&n.get()!==a))})(n)&&(n.set(c.constrain(n.get())),s||(s=window.setTimeout((function(){n.set(e.constrain(n.get())),r.useSpeed(10).useMass(3),o.start(),s=0}),70)))},toggleActive:function(n){u=!n}}}function v(n){var e=n.alignment,t=n.contentSize,r=n.viewSize,o=m({min:-t+r,max:0}),i=[e.measure(t)],a=t>r;return{measure:function(n,e){var t=n.map(o.constrain),r=function(n){var e=n[0],t=n[n.length-1];return m({min:n.lastIndexOf(e)+1,max:n.indexOf(t)})}(t),c=r.min,u=r.max;return a?e?t.slice(c-1,u+1):t:i}}}function x(n){var e=n.contentSize,t=n.location,r=n.limit,o=n.pxToPercent,i=m({min:r.min+o.measure(.1),max:r.max+o.measure(.1)}),a=i.reachedMin,c=i.reachedMax;return{loop:function(n,r){if(function(n){return 1===n?c(t.get()):-1===n&&a(t.get())}(r)){var o=e*(-1*r);n.forEach((function(n){return n.add(o)}))}}}}function h(n){var e=n.loop,t=n.limit,r=n.scrollSnaps,o=n.contentSize,i=t.reachedMax,a=t.reachedAny,c=t.removeOffset;function u(n,e){return Math.abs(n)<Math.abs(e)?n:e}function s(n,t){var r=n,i=n+o,a=n-o;if(!e)return r;if(!t)return u(u(r,i),a);var c=u(r,1===t?i:a);return Math.abs(c)*t}return{byDistance:function(t,o){var u=n.target.get()+t,l=function(n){var e=c(n);return{index:r.map((function(n){return n-e})).map((function(n){return s(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}}(u),d=function(t,r){if(!(!e&&a(t)))return r;var o=n.index,c=o.min,u=o.max;return i(t)?c:u}(u,l.index),f=!e&&a(u);return!o||f?{index:d,distance:t}:{index:d,distance:t+s(r[d]-l.distance,0)}},byIndex:function(e,t){return{index:e,distance:s(r[e]-n.target.get(),t)}},shortcut:s}}function S(n){var e,t=n.axis,r=n.location,o=n.slidesInView,a=n.direction,c=n.contentSize,u=n.viewSize,s=n.slideSizes,l=n.scrollSnaps,d=i(s),f=i(s).reverse(),m=(e=l[0]-1,x(v(f,e),"end")).concat(function(){var n=u-l[0]-1;return x(v(d,n),"start")}()),p="x"===t.scroll?"left":"top";function g(n,e){return n.reduce((function(n,e){return n-s[e]}),e)}function v(n,e){return n.reduce((function(n,t){return g(n,e)>0?n.concat([t]):n}),[])}function x(n,e){var t="start"===e,i=t?-c:c,a=o.findSlideBounds(i);return n.map((function(n){var e=t?0:-c,o=t?c:0,i=a.filter((function(e){return e.index===n}))[0][t?"end":"start"];return{point:i,getTarget:function(){return r.get()>i?e:o},index:n,location:-1}}))}return{canLoop:function(){return m.every((function(n){var e=n.index;return g(d.filter((function(n){return n!==e})),u)<=0}))},clear:function(n){m.forEach((function(e){var t=e.index;n[t].style[p]=""}))},loop:function(n){m.forEach((function(e){var t=e.getTarget,r=e.location,o=e.index,i=t();i!==r&&(n[o].style[p]=a.applyTo(i)+"%",e.location=i)}))},loopPoints:m}}function y(n){var e=n.scrollTo,t=n.slidesToScroll,r=n.root,o=s(),i=o.removeAll,a=0;function c(n){9===n.keyCode&&(a=(new Date).getTime())}function u(n,i){o.add(n,"focus",(function(){if(!((new Date).getTime()-a>10)){r.scrollLeft=0;var n=Math.floor(i/t);e.index(n,0)}}),!0)}return{addActivationEvents:function(n){o.add(document,"keydown",c,!1),n.forEach(u)},removeAllEvents:i}}function w(n){var e=n.axis,t=n.container,r=n.direction,i=t.style,a="x"===e.scroll?function(n){return"translate3d("+n+"%,0px,0px)"}:function(n){return"translate3d(0px,"+n+"%,0px)"},c=o(2),u=!1,s=0;return{clear:function(){i.transform="",s=0},to:function(n){var e=c(n.get());u||s===e||(getComputedStyle(t).transform,i.transform=a(r.applyTo(e)),s=e)},toggleActive:function(n){u=!n}}}function T(n,t,r,o,a){var c,s,T,b,M,z=o.align,A=o.axis,E=o.direction,P=o.startIndex,D=o.inViewThreshold,B=o.loop,I=o.speed,C=o.dragFree,L=o.slidesToScroll,k=o.containScroll,O=function(n){var e="y"===n?"y":"x";return{cross:"y"===n?"x":"y",measure:function(n){var t=n.getBoundingClientRect(),r=t.width,o=t.height;return"x"===e?r:o},scroll:e}}(A),V=(c=O.measure(t),{measure:function(n){return n/c*100},totalPercent:100}),F=V.totalPercent,N=r.map(O.measure).map(V.measure),U=i(N),H=function(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}(N,L).map((function(n){return n.reduce((function(n,e){return n+e}))})),j=N.reduce((function(n,e){return n+e}),0),q=e({align:z,viewSize:F}),R=function(n){var e,t=n.snapSizes,r=n.alignment,o=n.loop,i=t.map(r.measure),a=(e=u({limit:m({min:0,max:t.length-1}),start:0,loop:o}),t.map((function(n,t){var r=e.set(t+1).get();return n+i[t]-i[r]})));return{measure:function(n){return a.slice(0,n).reduce((function(n,e){return n-e}),i[0])}}}({snapSizes:H,alignment:q,loop:B}),X=i(H).map(R.measure),G=v({alignment:q,contentSize:j,viewSize:F}),Y=!B&&""!==k,J="trimSnaps"===k,K=G.measure(X,J),Q=Y?K:X,W=function(n){var e=n.contentSize,t=n.loop;return{measure:function(n){var r=n[0],o=n[n.length-1];return m({min:t?r-e:o,max:r})}}}({loop:B,contentSize:j}).measure(Q),Z=function(n){var e="rtl"===n?-1:1;return{applyTo:function(n){return n*e}}}(E),$=u({limit:m({min:0,max:Math.max(0,Q.length-1)}),start:P,loop:B}),_=$.clone(),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(){ln.scrollBody.seek(rn).update();var n=ln.scrollBody.settle(rn);ln.dragHandler.pointerDown()||(B||ln.scrollBounds.constrain(rn),n&&(ln.animation.stop(),a.emit("settle"))),B&&(ln.scrollLooper.loop(on,ln.scrollBody.direction()),ln.slideLooper.loop(r)),n||a.emit("scroll"),ln.translate.to(tn),ln.animation.proceed()})),en=Q[$.get()],tn=l(en),rn=l(en),on=[tn,rn],an=p({location:tn,speed:I,mass:1}),cn=h({contentSize:j,index:$,limit:W,loop:B,scrollSnaps:Q,target:rn}),un=function(n){var e=n.index,t=n.scrollTarget,r=n.animation,o=n.indexPrevious,i=n.events,a=n.target;function c(n){var t=n.distance,c=n.index!==e.get();t&&(r.start(),a.add(t)),c&&(o.set(e.get()),e.set(n.index),i.emit("select"))}return{distance:function(n,e){c(t.byDistance(n,e))},index:function(n,r){var o=e.clone().set(n);c(t.byIndex(o.get(),r))}}}({animation:nn,events:a,index:$,indexPrevious:_,scrollTarget:cn,target:rn}),sn=function(n){var e=n.contentSize,t=n.slideSizes,r=n.viewSize,o=n.inViewThreshold,a=n.loop,c=Math.min(Math.max(o,.01),.99),u=i(t).map((function(n){return t.slice(0,n).reduce((function(n,e){return n-e}),0)})),s=(a?[0,e,-e]:[0]).reduce((function(n,e){return n.concat(l(e,c))}),[]);function l(n,e){var o=t.map((function(n){return n*(e||0)}));return u.map((function(e,i){return{start:e-t[i]+o[i]+n,end:e+r-o[i]+n,index:i}}))}return{check:function(n){return s.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:l}}({contentSize:j,inViewThreshold:D,loop:B,slideSizes:N,viewSize:F}),ln={animation:nn,axis:O,direction:Z,dragHandler:d({animation:nn,axis:O,direction:Z,dragFree:C,dragTracker:f({axis:O,pxToPercent:V}),root:n,events:a,index:$,limit:W,location:tn,loop:B,scrollBody:an,scrollTo:un,scrollTarget:cn,target:rn}),pxToPercent:V,index:$,indexPrevious:_,limit:W,location:tn,options:o,scrollBody:an,scrollBounds:g({animation:nn,limit:W,location:tn,scrollBody:an}),scrollLooper:x({contentSize:j,limit:W,location:tn,pxToPercent:V}),scrollProgress:(s={limit:W},T=s.limit,b=T.max,M=T.length,{get:function(n){return(n-b)/-M}}),scrollSnaps:Q,scrollTarget:cn,scrollTo:un,slideFocus:y({root:n,scrollTo:un,slidesToScroll:L}),slideLooper:S({axis:O,contentSize:j,direction:Z,location:tn,scrollSnaps:Q,slideSizes:N,slidesInView:sn,viewSize:F}),slidesInView:sn,slideIndexes:U,target:rn,translate:w({axis:O,container:t,direction:Z})};return ln}var b={align:"center",axis:"x",containScroll:"",containerSelector:"*",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,l,d,f=function(){var n={destroy:[],pointerDown:[],pointerUp:[],init:[],reInit:[],resize:[],scroll:[],select:[],settle:[]},e={emit:function(t){return n[t].forEach((function(n){return n(t)})),e},off:function(t,r){return n[t]=n[t].filter((function(n){return n!==r})),e},on:function(t,r){return n[t]=n[t].concat([r]),e}};return e}(),m=s(),p=(r=function(){if(h){var n=u.axis.measure(e);y!==n&&E(),f.emit("resize")}},o=500,i=0,function(){window.clearTimeout(i),i=window.setTimeout(r,o)||0}),g=E,v=f.on,x=f.off,h=!1,S=n({},b),y=0;function w(t){if(function(){if(!e)throw new Error("Missing root node 😢");var n=S.containerSelector,t=e.querySelector(n);if(!t)throw new Error("Missing container node 😢");l=t,d=Array.prototype.slice.call(l.children)}(),S=n(S,t),u=T(e,l,d,S,f),y=u.axis.measure(e),m.add(window,"resize",p),u.translate.to(u.location),S.loop){if(!u.slideLooper.canLoop())return A(),w({loop:!1});u.slideLooper.loop(d)}S.draggable&&d.length&&(u.dragHandler.addActivationEvents(),S.draggableClass&&c(e,S.draggableClass),S.draggingClass&&f.on("pointerDown",M).on("pointerUp",M)),d.length&&u.slideFocus.addActivationEvents(d),S.selectedClass&&(z(),f.on("select",z).on("pointerUp",z)),h||(setTimeout((function(){return f.emit("init")}),0),h=!0)}function M(n){var t=S.draggingClass;"pointerDown"===n?c(e,t):a(e,t)}function z(){var n=S.selectedClass,e=P(!0);D(!0).forEach((function(e){return a(d[e],n)})),e.forEach((function(e){return c(d[e],n)}))}function A(){u.dragHandler.removeAllEvents(),u.slideFocus.removeAllEvents(),u.animation.stop(),m.removeAll(),u.translate.clear(),u.slideLooper.clear(d),a(e,S.draggableClass),d.forEach((function(n){return a(n,S.selectedClass)})),f.off("select",z),f.off("pointerUp",z),f.off("pointerDown",M),f.off("pointerUp",M)}function E(e){if(h){var t=n({startIndex:I()},e);A(),w(t),f.emit("reInit")}}function P(n){var e=u[n?"target":"location"].get(),t=S.loop?"removeOffset":"constrain";return u.slidesInView.check(u.limit[t](e))}function D(n){var e=P(n);return u.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}function B(n,e){u.scrollBody.useBaseMass().useBaseSpeed(),h&&u.scrollTo.index(n,e||0)}function I(){return u.index.get()}return w(t),{canScrollNext:function(){return u.index.clone().add(1).get()!==I()},canScrollPrev:function(){return u.index.clone().add(-1).get()!==I()},clickAllowed:function(){return u.dragHandler.clickAllowed()},containerNode:function(){return l},dangerouslyGetEngine:function(){return u},destroy:function(){h&&(A(),h=!1,f.emit("destroy"))},off:x,on:v,previousScrollSnap:function(){return u.indexPrevious.get()},reInit:g,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:I,slideNodes:function(){return d},slidesInView:P,slidesNotInView:D}}}));
!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){var e=n.viewSize,t=n.align,r={start:function(){return 0},center:function(n){return o(n)/2},end:o};function o(n){return e-n}return{measure:function(n){return"number"==typeof t?e*Number(t):r[t](n)}}}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){return Object.keys(n).map(Number)}function a(n,e){var t=n.classList;e&&t.contains(e)&&t.remove(e)}function c(n,e){var t=n.classList;e&&!t.contains(e)&&t.add(e)}function u(n){var e=n.start,r=n.limit,o=n.loop,i=r.min,a=r.max,c=r[o?"loop":"constrain"],s=c(e);function l(){return s}function d(n){return s=c(n),f}var f={add:function n(e){if(0!==e){var r=t(e);return d(l()+r),n(e+-1*r)}return f},clone:function(){return u({start:l(),limit:r,loop:o})},get:l,max:a,min:i,set:d};return f}function s(){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 d(n){var e=n.target,o=n.scrollBody,i=n.dragFree,a=n.animation,c=n.axis,u=n.scrollTo,d=n.root,f=n.dragTracker,m=n.location,p=n.events,v=n.limit,g=n.direction,x=c.scroll,h=c.cross,S=["INPUT","SELECT","TEXTAREA"],y=l(0),w=l(0),b=l(0),T=s(),M=s(),z={mouse:2.5,touch:3.5},A={mouse:5,touch:7},E=i?5:12,P=!1,D=!1,B=!1,I=!1;function C(n){if(!(I="mousedown"===n.type)||0===n.button){var t,i,a=r(e.get(),m.get())>=2,c=I||!a,u=(t=n.target,i=t.nodeName||"",!(S.indexOf(i)>-1)),s=a||I&&u;P=!0,f.pointerDown(n),b.set(e),e.set(m),o.useBaseMass().useSpeed(80),function(){var n=I?document:d;M.add(n,"touchmove",L).add(n,"touchend",k).add(n,"mousemove",L).add(n,"mouseup",k)}(),y.set(f.readPoint(n,x)),w.set(f.readPoint(n,h)),p.emit("pointerDown"),c&&(B=!1),s&&n.preventDefault()}}function L(n){if(!D&&!I){if(!n.cancelable)return k();var t=f.readPoint(n,x).get(),o=f.readPoint(n,h).get(),i=r(t,y.get()),c=r(o,w.get());if(!(D=i>c)&&!B)return k()}var u=f.pointerMove(n);!B&&u&&(B=!0),a.start(),e.add(g.applyTo(u)),n.preventDefault()}function k(){var a=f.pointerUp()*(i?A:z)[I?"mouse":"touch"],c=function(e){var r=n.scrollTarget,o=n.index,a=!(r.byDistance(0,!1).index!==o.get())&&Math.abs(e)>4,c=e+m.get();if(a&&!i&&!v.reachedAny(c)){var u=o.clone().add(-1*t(e));return r.byIndex(u.get(),0).distance}return r.byDistance(e,!i).distance}(g.applyTo(a)),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)}(a,c);r(e.get(),b.get())>=.5&&!I&&(B=!0),D=!1,P=!1,M.removeAll(),o.useSpeed(E+E*s),u.distance(c,!i),I=!1,p.emit("pointerUp")}function O(n){B&&n.preventDefault()}return{addActivationEvents:function(){var n=d;T.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",C).add(n,"mousedown",C).add(n,"touchcancel",k).add(n,"contextmenu",k).add(n,"click",O)},clickAllowed:function(){return!B},pointerDown:function(){return P},removeAllEvents:function(){T.removeAll(),M.removeAll()}}}function f(n){var e=n.axis,t=n.pxToPercent,r=e.scroll,o={x:"clientX",y:"clientY"},i=l(0),a=l(0),c=l(0),u=l(0),s=[],d=(new Date).getTime(),f=!1;function m(n,e){f=!n.touches;var t=o[e],r=f?n[t]:n.touches[0][t];return u.set(r)}return{pointerDown:function(n){var e=m(n,r);return i.set(e),c.set(e),t.measure(i.get())},pointerMove:function(n){var e=m(n,r),o=(new Date).getTime(),i=o-d;return i>=10&&(i>=100&&(s=[]),s.push(e.get()),d=o),a.set(e).subtract(c),c.set(e),t.measure(a.get())},pointerUp:function(){var n=(new Date).getTime()-d,e=c.get(),r=s.slice(-5).map((function(n){return e-n})).sort((function(n,e){return Math.abs(n)<Math.abs(e)?1:-1}))[0];return c.set(n>100||!r?0:r),s=[],t.measure(c.get())},readPoint:m}}function m(n){var e=n.min,t=n.max,r=Math.abs(e-t);function o(n){return n<e}function i(n){return n>t}function a(n){return o(n)||i(n)}return{constrain:function(n){return a(n)?o(n)?e:t:n},length:r,loop:function(n){return a(n)?o(n)?t:e:n},max:t,min:e,reachedAny:a,reachedMax:i,reachedMin:o,removeOffset:function(n){if(e===t)return n;for(;o(n);)n+=r;for(;i(n);)n-=r;return n}}}function p(n){var e=n.location,r=n.speed,i=n.mass,a=o(2),c=l(0),u=l(0),s=l(0),d=0,f=r,m=i;function p(n){return f=n,g}function v(n){return m=n,g}var g={direction:function(){return d},seek:function(n){s.set(n).subtract(e);var r,o,i=s.get(),a=(o=0)+(i-(r=0))/(100-r)*(f-o);return d=t(s.get()),s.normalize().multiply(a).subtract(c),function(n){n.divide(m),u.add(n)}(s),g},settle:function(n){var t=n.get()-e.get(),r=!a(t);return r&&e.set(n),r},update:function(){c.add(u),e.add(c),u.multiply(0)},useBaseMass:function(){return v(i)},useBaseSpeed:function(){return p(r)},useMass:v,useSpeed:p};return g}function v(n){var e=n.limit,t=n.location,r=n.scrollBody,o=!1;return{constrain:function(n,i){if(function(n){return!o&&(!!e.reachedAny(n.get())&&!!e.reachedAny(t.get()))}(n)){var a=i?.7:.4,c=n.get()-t.get();n.subtract(c*a),!i&&Math.abs(c)<10&&(n.set(e.constrain(n.get())),r.useSpeed(10).useMass(3))}},toggleActive:function(n){o=!n}}}function g(n){var e=n.alignment,t=n.contentSize,r=n.viewSize,o=m({min:-t+r,max:0}),i=[e.measure(t)],a=t>r;return{measure:function(n,e){var t=n.map(o.constrain),r=function(n){var e=n[0],t=n[n.length-1];return m({min:n.lastIndexOf(e)+1,max:n.indexOf(t)})}(t),c=r.min,u=r.max;return a?e?t.slice(c-1,u+1):t:i}}}function x(n){var e=n.contentSize,t=n.location,r=n.limit,o=n.pxToPercent,i=m({min:r.min+o.measure(.1),max:r.max+o.measure(.1)}),a=i.reachedMin,c=i.reachedMax;return{loop:function(n,r){if(function(n){return 1===n?c(t.get()):-1===n&&a(t.get())}(r)){var o=e*(-1*r);n.forEach((function(n){return n.add(o)}))}}}}function h(n){var e=n.loop,t=n.limit,r=n.scrollSnaps,o=n.contentSize,i=t.reachedMax,a=t.reachedAny,c=t.removeOffset;function u(n,e){return Math.abs(n)<Math.abs(e)?n:e}function s(n,t){var r=n,i=n+o,a=n-o;if(!e)return r;if(!t)return u(u(r,i),a);var c=u(r,1===t?i:a);return Math.abs(c)*t}return{byDistance:function(t,o){var u=n.target.get()+t,l=function(n){var e=c(n);return{index:r.map((function(n){return n-e})).map((function(n){return s(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}}(u),d=function(t,r){if(!(!e&&a(t)))return r;var o=n.index,c=o.min,u=o.max;return i(t)?c:u}(u,l.index),f=!e&&a(u);return!o||f?{index:d,distance:t}:{index:d,distance:t+s(r[d]-l.distance,0)}},byIndex:function(e,t){return{index:e,distance:s(r[e]-n.target.get(),t)}},shortcut:s}}function S(n){var e,t=n.axis,r=n.location,o=n.slidesInView,a=n.direction,c=n.contentSize,u=n.viewSize,s=n.slideSizes,l=n.scrollSnaps,d=i(s),f=i(s).reverse(),m=(e=l[0]-1,x(g(f,e),"end")).concat(function(){var n=u-l[0]-1;return x(g(d,n),"start")}()),p="x"===t.scroll?"left":"top";function v(n,e){return n.reduce((function(n,e){return n-s[e]}),e)}function g(n,e){return n.reduce((function(n,t){return v(n,e)>0?n.concat([t]):n}),[])}function x(n,e){var t="start"===e,i=t?-c:c,a=o.findSlideBounds(i);return n.map((function(n){var e=t?0:-c,o=t?c:0,i=a.filter((function(e){return e.index===n}))[0][t?"end":"start"];return{point:i,getTarget:function(){return r.get()>i?e:o},index:n,location:-1}}))}return{canLoop:function(){return m.every((function(n){var e=n.index;return v(d.filter((function(n){return n!==e})),u)<=0}))},clear:function(n){m.forEach((function(e){var t=e.index;n[t].style[p]=""}))},loop:function(n){m.forEach((function(e){var t=e.getTarget,r=e.location,o=e.index,i=t();i!==r&&(n[o].style[p]=a.applyTo(i)+"%",e.location=i)}))},loopPoints:m}}function y(n){var e=n.scrollTo,t=n.slidesToScroll,r=n.root,o=s(),i=o.removeAll,a=0;function c(n){9===n.keyCode&&(a=(new Date).getTime())}function u(n,i){o.add(n,"focus",(function(){if(!((new Date).getTime()-a>10)){r.scrollLeft=0;var n=Math.floor(i/t);e.index(n,0)}}),!0)}return{addActivationEvents:function(n){o.add(document,"keydown",c,!1),n.forEach(u)},removeAllEvents:i}}function w(n){var e=n.axis,t=n.container,r=n.direction,i=t.style,a="x"===e.scroll?function(n){return"translate3d("+n+"%,0px,0px)"}:function(n){return"translate3d(0px,"+n+"%,0px)"},c=o(2),u=!1,s=0;return{clear:function(){i.transform="",s=0},to:function(n){var e=c(n.get());u||s===e||(getComputedStyle(t).transform,i.transform=a(r.applyTo(e)),s=e)},toggleActive:function(n){u=!n}}}function b(n,t,r,o,a){var c,s,b,T,M,z=o.align,A=o.axis,E=o.direction,P=o.startIndex,D=o.inViewThreshold,B=o.loop,I=o.speed,C=o.dragFree,L=o.slidesToScroll,k=o.containScroll,O=function(n){var e="y"===n?"y":"x";return{cross:"y"===n?"x":"y",measure:function(n){var t=n.getBoundingClientRect(),r=t.width,o=t.height;return"x"===e?r:o},scroll:e}}(A),V=(c=O.measure(t),{measure:function(n){return n/c*100},totalPercent:100}),F=V.totalPercent,N=r.map(O.measure).map(V.measure),U=i(N),H=function(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}(N,L).map((function(n){return n.reduce((function(n,e){return n+e}))})),j=N.reduce((function(n,e){return n+e}),0),q=e({align:z,viewSize:F}),R=function(n){var e,t=n.snapSizes,r=n.alignment,o=n.loop,i=t.map(r.measure),a=(e=u({limit:m({min:0,max:t.length-1}),start:0,loop:o}),t.map((function(n,t){var r=e.set(t+1).get();return n+i[t]-i[r]})));return{measure:function(n){return a.slice(0,n).reduce((function(n,e){return n-e}),i[0])}}}({snapSizes:H,alignment:q,loop:B}),X=i(H).map(R.measure),G=g({alignment:q,contentSize:j,viewSize:F}),Y=!B&&""!==k,J="trimSnaps"===k,K=G.measure(X,J),Q=Y?K:X,W=function(n){var e=n.contentSize,t=n.loop;return{measure:function(n){var r=n[0],o=n[n.length-1];return m({min:t?r-e:o,max:r})}}}({loop:B,contentSize:j}).measure(Q),Z=function(n){var e="rtl"===n?-1:1;return{applyTo:function(n){return n*e}}}(E),$=u({limit:m({min:0,max:Math.max(0,Q.length-1)}),start:P,loop:B}),_=$.clone(),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(){B||ln.scrollBounds.constrain(rn,ln.dragHandler.pointerDown()),ln.scrollBody.seek(rn).update();var n=ln.scrollBody.settle(rn);n&&!ln.dragHandler.pointerDown()&&(ln.animation.stop(),a.emit("settle")),n||a.emit("scroll"),B&&(ln.scrollLooper.loop(on,ln.scrollBody.direction()),ln.slideLooper.loop(r)),ln.translate.to(tn),ln.animation.proceed()})),en=Q[$.get()],tn=l(en),rn=l(en),on=[tn,rn],an=p({location:tn,speed:I,mass:1}),cn=h({contentSize:j,index:$,limit:W,loop:B,scrollSnaps:Q,target:rn}),un=function(n){var e=n.index,t=n.scrollTarget,r=n.animation,o=n.indexPrevious,i=n.events,a=n.target;function c(n){var t=n.distance,c=n.index!==e.get();t&&(r.start(),a.add(t)),c&&(o.set(e.get()),e.set(n.index),i.emit("select"))}return{distance:function(n,e){c(t.byDistance(n,e))},index:function(n,r){var o=e.clone().set(n);c(t.byIndex(o.get(),r))}}}({animation:nn,events:a,index:$,indexPrevious:_,scrollTarget:cn,target:rn}),sn=function(n){var e=n.contentSize,t=n.slideSizes,r=n.viewSize,o=n.inViewThreshold,a=n.loop,c=Math.min(Math.max(o,.01),.99),u=i(t).map((function(n){return t.slice(0,n).reduce((function(n,e){return n-e}),0)})),s=(a?[0,e,-e]:[0]).reduce((function(n,e){return n.concat(l(e,c))}),[]);function l(n,e){var o=t.map((function(n){return n*(e||0)}));return u.map((function(e,i){return{start:e-t[i]+o[i]+n,end:e+r-o[i]+n,index:i}}))}return{check:function(n){return s.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:l}}({contentSize:j,inViewThreshold:D,loop:B,slideSizes:N,viewSize:F}),ln={animation:nn,axis:O,direction:Z,dragHandler:d({animation:nn,axis:O,direction:Z,dragFree:C,dragTracker:f({axis:O,pxToPercent:V}),root:n,events:a,index:$,limit:W,location:tn,scrollBody:an,scrollTo:un,scrollTarget:cn,target:rn}),pxToPercent:V,index:$,indexPrevious:_,limit:W,location:tn,options:o,scrollBody:an,scrollBounds:v({limit:W,location:tn,scrollBody:an}),scrollLooper:x({contentSize:j,limit:W,location:tn,pxToPercent:V}),scrollProgress:(s={limit:W},b=s.limit,T=b.max,M=b.length,{get:function(n){return(n-T)/-M}}),scrollSnaps:Q,scrollTarget:cn,scrollTo:un,slideFocus:y({root:n,scrollTo:un,slidesToScroll:L}),slideLooper:S({axis:O,contentSize:j,direction:Z,location:tn,scrollSnaps:Q,slideSizes:N,slidesInView:sn,viewSize:F}),slidesInView:sn,slideIndexes:U,target:rn,translate:w({axis:O,container:t,direction:Z})};return ln}var T={align:"center",axis:"x",containScroll:"",containerSelector:"*",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,l,d,f=function(){var n={destroy:[],pointerDown:[],pointerUp:[],init:[],reInit:[],resize:[],scroll:[],select:[],settle:[]},e={emit:function(t){return n[t].forEach((function(n){return n(t)})),e},off:function(t,r){return n[t]=n[t].filter((function(n){return n!==r})),e},on:function(t,r){return n[t]=n[t].concat([r]),e}};return e}(),m=s(),p=(r=function(){if(h){var n=u.axis.measure(e);y!==n&&E(),f.emit("resize")}},o=500,i=0,function(){window.clearTimeout(i),i=window.setTimeout(r,o)||0}),v=E,g=f.on,x=f.off,h=!1,S=n({},T),y=0;function w(t){if(function(){if(!e)throw new Error("Missing root node 😢");var n=S.containerSelector,t=e.querySelector(n);if(!t)throw new Error("Missing container node 😢");l=t,d=Array.prototype.slice.call(l.children)}(),S=n(S,t),u=b(e,l,d,S,f),y=u.axis.measure(e),m.add(window,"resize",p),u.translate.to(u.location),S.loop){if(!u.slideLooper.canLoop())return A(),w({loop:!1});u.slideLooper.loop(d)}S.draggable&&d.length&&(u.dragHandler.addActivationEvents(),S.draggableClass&&c(e,S.draggableClass),S.draggingClass&&f.on("pointerDown",M).on("pointerUp",M)),d.length&&u.slideFocus.addActivationEvents(d),S.selectedClass&&(z(),f.on("select",z).on("pointerUp",z)),h||(setTimeout((function(){return f.emit("init")}),0),h=!0)}function M(n){var t=S.draggingClass;"pointerDown"===n?c(e,t):a(e,t)}function z(){var n=S.selectedClass,e=P(!0);D(!0).forEach((function(e){return a(d[e],n)})),e.forEach((function(e){return c(d[e],n)}))}function A(){u.dragHandler.removeAllEvents(),u.slideFocus.removeAllEvents(),u.animation.stop(),m.removeAll(),u.translate.clear(),u.slideLooper.clear(d),a(e,S.draggableClass),d.forEach((function(n){return a(n,S.selectedClass)})),f.off("select",z),f.off("pointerUp",z),f.off("pointerDown",M),f.off("pointerUp",M)}function E(e){if(h){var t=n({startIndex:I()},e);A(),w(t),f.emit("reInit")}}function P(n){var e=u[n?"target":"location"].get(),t=S.loop?"removeOffset":"constrain";return u.slidesInView.check(u.limit[t](e))}function D(n){var e=P(n);return u.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}function B(n,e){u.scrollBody.useBaseMass().useBaseSpeed(),h&&u.scrollTo.index(n,e||0)}function I(){return u.index.get()}return w(t),{canScrollNext:function(){return u.index.clone().add(1).get()!==I()},canScrollPrev:function(){return u.index.clone().add(-1).get()!==I()},clickAllowed:function(){return u.dragHandler.clickAllowed()},containerNode:function(){return l},dangerouslyGetEngine:function(){return u},destroy:function(){h&&(A(),h=!1,f.emit("destroy"))},off:x,on:g,previousScrollSnap:function(){return u.indexPrevious.get()},reInit:v,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:I,slideNodes:function(){return d},slidesInView:P,slidesNotInView:D}}}));
{
"name": "embla-carousel",
"version": "4.1.1",
"version": "4.1.2",
"private": false,

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

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

var diff = dragTracker.pointerMove(evt);
var reachedLimit = limit.reachedAny(location.get());
var resist = !params.loop && reachedLimit ? 4 : 1;
if (!preventClick && diff) preventClick = true;
animation.start();
target.add(direction.applyTo(diff / resist));
target.add(direction.applyTo(diff));
evt.preventDefault();

@@ -674,32 +672,22 @@ }

location = params.location,
scrollBody = params.scrollBody,
animation = params.animation;
var min = limit.min,
max = limit.max;
var tolerance = 70;
var edgeLimit = Limit({
min: min - tolerance,
max: max + tolerance
});
scrollBody = params.scrollBody;
var pullBackThreshold = 10;
var disabled = false;
var timeout = 0;
function shouldConstrain(target) {
if (disabled) return false;
if (!limit.reachedAny(target.get())) return false;
if (!limit.reachedAny(location.get())) return false;
if (target.get() === min || target.get() === max) return false;
return true;
}
function constrain(target) {
function constrain(target, pointerDown) {
if (!shouldConstrain(target)) return;
target.set(edgeLimit.constrain(target.get()));
var friction = pointerDown ? 0.7 : 0.4;
var diffToTarget = target.get() - location.get();
target.subtract(diffToTarget * friction);
if (!timeout) {
timeout = window.setTimeout(function () {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
animation.start();
timeout = 0;
}, tolerance);
if (!pointerDown && Math.abs(diffToTarget) < pullBackThreshold) {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
}

@@ -1298,12 +1286,16 @@ }

var update = function update() {
if (!loop) {
engine.scrollBounds.constrain(target, engine.dragHandler.pointerDown());
}
engine.scrollBody.seek(target).update();
var settled = engine.scrollBody.settle(target);
if (!engine.dragHandler.pointerDown()) {
if (!loop) engine.scrollBounds.constrain(target);
if (settled && !engine.dragHandler.pointerDown()) {
engine.animation.stop();
events.emit('settle');
}
if (settled) {
engine.animation.stop();
events.emit('settle');
}
if (!settled) {
events.emit('scroll');
}

@@ -1316,3 +1308,2 @@

if (!settled) events.emit('scroll');
engine.translate.to(location);

@@ -1371,3 +1362,2 @@ engine.animation.proceed();

location: location,
loop: loop,
scrollBody: scrollBody,

@@ -1392,3 +1382,2 @@ scrollTo: scrollTo,

scrollBounds: ScrollBounds({
animation: animation,
limit: limit,

@@ -1395,0 +1384,0 @@ location: location,

@@ -413,7 +413,5 @@ 'use strict';

var diff = dragTracker.pointerMove(evt);
var reachedLimit = limit.reachedAny(location.get());
var resist = !params.loop && reachedLimit ? 4 : 1;
if (!preventClick && diff) preventClick = true;
animation.start();
target.add(direction.applyTo(diff / resist));
target.add(direction.applyTo(diff));
evt.preventDefault();

@@ -678,32 +676,22 @@ }

location = params.location,
scrollBody = params.scrollBody,
animation = params.animation;
var min = limit.min,
max = limit.max;
var tolerance = 70;
var edgeLimit = Limit({
min: min - tolerance,
max: max + tolerance
});
scrollBody = params.scrollBody;
var pullBackThreshold = 10;
var disabled = false;
var timeout = 0;
function shouldConstrain(target) {
if (disabled) return false;
if (!limit.reachedAny(target.get())) return false;
if (!limit.reachedAny(location.get())) return false;
if (target.get() === min || target.get() === max) return false;
return true;
}
function constrain(target) {
function constrain(target, pointerDown) {
if (!shouldConstrain(target)) return;
target.set(edgeLimit.constrain(target.get()));
var friction = pointerDown ? 0.7 : 0.4;
var diffToTarget = target.get() - location.get();
target.subtract(diffToTarget * friction);
if (!timeout) {
timeout = window.setTimeout(function () {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
animation.start();
timeout = 0;
}, tolerance);
if (!pointerDown && Math.abs(diffToTarget) < pullBackThreshold) {
target.set(limit.constrain(target.get()));
scrollBody.useSpeed(10).useMass(3);
}

@@ -1302,12 +1290,16 @@ }

var update = function update() {
if (!loop) {
engine.scrollBounds.constrain(target, engine.dragHandler.pointerDown());
}
engine.scrollBody.seek(target).update();
var settled = engine.scrollBody.settle(target);
if (!engine.dragHandler.pointerDown()) {
if (!loop) engine.scrollBounds.constrain(target);
if (settled && !engine.dragHandler.pointerDown()) {
engine.animation.stop();
events.emit('settle');
}
if (settled) {
engine.animation.stop();
events.emit('settle');
}
if (!settled) {
events.emit('scroll');
}

@@ -1320,3 +1312,2 @@

if (!settled) events.emit('scroll');
engine.translate.to(location);

@@ -1375,3 +1366,2 @@ engine.animation.proceed();

location: location,
loop: loop,
scrollBody: scrollBody,

@@ -1396,3 +1386,2 @@ scrollTo: scrollTo,

scrollBounds: ScrollBounds({
animation: animation,
limit: limit,

@@ -1399,0 +1388,0 @@ location: location,

<br />
<div align="center">
<p align="center">
<a href="https://davidcetinkaya.github.io/embla-carousel" target="_blank"><img width="70" height="70" src="https://davidcetinkaya.github.io/embla-carousel/build/img/embla-logo.svg" alt="Embla Carousel">
<a href="https://davidcetinkaya.github.io/embla-carousel"><img width="70" height="70" src="https://davidcetinkaya.github.io/embla-carousel/build/img/embla-logo.svg" alt="Embla Carousel">
</a>

@@ -9,9 +9,8 @@ </p>

<p align="center">
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/license-MIT-green.svg"></a>
<a href="https://www.npmjs.com/package/embla-carousel" target="_blank"><img src="https://img.shields.io/npm/v/embla-carousel.svg"></a>
<a href="https://github.com/davidcetinkaya/embla-carousel/actions?query=workflow%3A%22Continuous+Integration%22" target="_blank"><img src="https://img.shields.io/github/workflow/status/davidcetinkaya/embla-carousel/Continuous%20Integration"></a>
<a href="https://prettier.io" target="_blank"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat"></a>
<a href="https://www.npmjs.com/package/embla-carousel" target="_blank"><img src="https://img.shields.io/bundlephobia/minzip/embla-carousel?color=%234c1&label=gzip%20size">
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-green.svg"></a>
<a href="https://www.npmjs.com/package/embla-carousel"><img src="https://img.shields.io/npm/v/embla-carousel.svg"></a>
<a href="https://github.com/davidcetinkaya/embla-carousel/actions?query=workflow%3A%22Continuous+Integration%22"><img src="https://img.shields.io/github/workflow/status/davidcetinkaya/embla-carousel/Continuous%20Integration"></a>
<a href="https://prettier.io"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat"></a>
<a href="https://bundlephobia.com/result?p=embla-carousel@latest"><img src="https://img.shields.io/bundlephobia/minzip/embla-carousel?color=%234c1&label=gzip%20size">
</a>
</p>

@@ -95,5 +94,5 @@

<a href="https://github.com/msallent"><img src="https://avatars3.githubusercontent.com/u/8879212?s=120&v=4" title="msallent" width="60" height="60" style="max-width:100%;"></a>
<a href="https://github.com/omarkhatibco"><img src="https://avatars1.githubusercontent.com/u/9054278?s=120&v=4" title="msallent" width="60" height="60" style="max-width:100%;"></a>
<a href="https://github.com/ppromerojr"><img src="https://avatars1.githubusercontent.com/u/15343254?s=120&v=4" title="wopian" width="60" height="60" style="max-width:100%;"></a>
<a href="https://github.com/openscript"><img src="https://avatars3.githubusercontent.com/u/1105080?s=120&v=4" title="wopian" width="60" height="60" style="max-width:100%;"></a>
<a href="https://github.com/omarkhatibco"><img src="https://avatars1.githubusercontent.com/u/9054278?s=120&v=4" title="omarkhatibco" width="60" height="60" style="max-width:100%;"></a>
<a href="https://github.com/ppromerojr"><img src="https://avatars1.githubusercontent.com/u/15343254?s=120&v=4" title="ppromerojr" width="60" height="60" style="max-width:100%;"></a>
<a href="https://github.com/openscript"><img src="https://avatars3.githubusercontent.com/u/1105080?s=120&v=4" title="openscript" width="60" height="60" style="max-width:100%;"></a>

@@ -133,4 +132,4 @@ </p>

<a href="https://www.browserstack.com">
<img src="https://davidcetinkaya.github.io/embla-carousel/build/img/browserstack-logo.svg" height="50" />
<img src="https://davidcetinkaya.github.io/embla-carousel/build/img/browserstack-logo.svg" width="170" height="50" />
</a>
</p>

@@ -26,3 +26,2 @@ import { Animation } from './animation';

limit: Limit;
loop: boolean;
events: EventEmitter;

@@ -29,0 +28,0 @@ };

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

import { Animation } from './animation';
import { Limit } from './limit';

@@ -9,6 +8,5 @@ import { ScrollBody } from './scrollBody';

scrollBody: ScrollBody;
animation: Animation;
};
export declare type ScrollBounds = {
constrain: (v: Vector1D) => void;
constrain: (v: Vector1D, pointerDown: boolean) => void;
toggleActive: (active: boolean) => void;

@@ -15,0 +13,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