embla-carousel
Advanced tools
Comparing version 4.0.4 to 4.0.5
@@ -605,7 +605,7 @@ function _extends() { | ||
var cl = node.classList; | ||
if (cl.contains(className)) cl.remove(className); | ||
if (className && cl.contains(className)) cl.remove(className); | ||
} | ||
function addClass(node, className) { | ||
var cl = node.classList; | ||
if (!cl.contains(className)) cl.add(className); | ||
if (className && !cl.contains(className)) cl.add(className); | ||
} | ||
@@ -612,0 +612,0 @@ |
@@ -607,7 +607,7 @@ 'use strict'; | ||
var cl = node.classList; | ||
if (cl.contains(className)) cl.remove(className); | ||
if (className && cl.contains(className)) cl.remove(className); | ||
} | ||
function addClass(node, className) { | ||
var cl = node.classList; | ||
if (!cl.contains(className)) cl.add(className); | ||
if (className && !cl.contains(className)) cl.add(className); | ||
} | ||
@@ -614,0 +614,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){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){var e=n.start,r=n.limit,o=n.loop,i=r.min,a=r.max,c=r[o?"loop":"constrain"],u=c(e);function s(){return u}function l(n){return u=c(n),d}var d={add:function n(e){if(0!==e){var t=e/Math.abs(e);return l(s()+t),n(e+-1*t)}return d},clone:function(){return t({start:s(),limit:r,loop:o})},get:s,max:a,min:i,set:l};return d}function r(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 o(n){var e=r(t(n));function t(n){return 0===n?0:n/Math.abs(n)}var o={get:e.get,set:function(n){var r=t(n.get());return 0!==r&&e.set(r),o}};return o}function i(){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 a(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 c(n){var e=n.target,t=n.scrollBody,c=n.dragFree,u=n.animation,s=n.axis,l=n.element,d=n.dragTracker,f=n.location,m=n.events,p=n.limit,g=s.scroll,v=s.cross,x=["INPUT","SELECT","TEXTAREA"],h=r(0),S=r(0),w=r(0),y=i(),b=i(),T={mouse:2.5,touch:3.5},M={mouse:5,touch:7},z=c?5:12,A=a({min:p.min-70,max:p.max+70}),D=!1,E=!1,P=!1,I=!1;function B(n){if(!(I="mousedown"===n.type)||0===n.button){var r,o,i=k(e.get(),f.get())>=2,a=I||!i,c=(r=n.target,o=r.nodeName||"",!(x.indexOf(o)>-1)),u=i||I&&c;D=!0,d.pointerDown(n),w.set(e),e.set(f),t.useDefaultMass().useSpeed(80),function(){var n=I?document:l;b.add(n,"touchmove",C).add(n,"touchend",L).add(n,"mousemove",C).add(n,"mouseup",L)}(),h.set(d.readPoint(n,g)),S.set(d.readPoint(n,v)),m.emit("pointerDown"),a&&(P=!1),u&&n.preventDefault()}}function C(t){if(!E&&!I){if(!t.cancelable)return L();var r=d.readPoint(t,g).get(),o=d.readPoint(t,v).get(),i=k(r,h.get()),a=k(o,S.get());if(!(E=i>a)&&!P)return L()}var c=d.pointerMove(t),s=p.reachedAny(f.get()),l=!n.loop&&s?2:1;!P&&c&&(P=!0),u.start(),e.add(c/l),t.preventDefault()}function L(){var r,i,a,u=n.scrollTo,s=d.pointerUp()*(c?M:T)[I?"mouse":"touch"],l=function(t){var r=n.scrollTarget,i=n.index,a=!(r.byDistance(0,!1).index!==i.get())&&Math.abs(t)>4,u=t+f.get();if(a&&!c&&!p.reachedAny(u)){var s=i.clone().add(-1*o(t).get());return r.byIndex(s.get(),0).distance}if(!n.loop&&A.reachedAny(u)){var l=A.reachedMax(u)?"max":"min";return A[l]-e.get()}return r.byDistance(t,!c).distance}(s),g=(r=s,i=l,a=k(Math.abs(r),Math.abs(i)),Math.abs(r)<=Math.abs(i)||0===r||0===i?0:Math.abs(a/r));k(e.get(),w.get())>=.5&&!I&&(P=!0),E=!1,D=!1,b.removeAll(),t.useSpeed(z+z*g),u.distance(l,!c),I=!1,m.emit("pointerUp")}function k(n,e){return Math.abs(n-e)}function O(n){P&&n.preventDefault()}return{addActivationEvents:function(){var n=l;y.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",B).add(n,"mousedown",B).add(n,"touchcancel",L).add(n,"contextmenu",L).add(n,"click",O)},clickAllowed:function(){return!P},pointerDown:function(){return D},removeAllEvents:function(){y.removeAll(),b.removeAll()}}}function u(n){var e=n.axis,t=n.pxToPercent,o=e.scroll,i={x:"clientX",y:"clientY"},a=r(0),c=r(0),u=r(0),s=r(0),l=[],d=(new Date).getTime(),f=!1;function m(n,e){f=!n.touches;var t=i[e],r=f?n[t]:n.touches[0][t];return s.set(r)}return{pointerDown:function(n){var e=m(n,o);return a.set(e),u.set(e),t.measure(a.get())},pointerMove:function(n){var e=m(n,o),r=(new Date).getTime(),i=r-d;return i>=10&&(i>=100&&(l=[]),l.push(e.get()),d=r),c.set(e).subtract(u),u.set(e),t.measure(c.get())},pointerUp:function(){var n=(new Date).getTime()-d,e=u.get(),r=l.slice(-5).map((function(n){return e-n})).sort((function(n,e){return Math.abs(n)<Math.abs(e)?1:-1}))[0];return u.set(n>100||!r?0:r),l=[],t.measure(u.get())},readPoint:m}}function s(n){var e=Math.pow(10,n);return function(n){return Math.round(n*e)/e}}function l(n){return Object.keys(n).map(Number)}function d(n,e){var t=n.classList;t.contains(e)&&t.remove(e)}function f(n,e){var t=n.classList;t.contains(e)||t.add(e)}function m(n){var e=n.location,t=n.speed,i=n.mass,a=s(2),c=r(0),u=r(0),l=r(0),d=o(0),f={speed:t,mass:i};function m(n){return f.speed=n,g}function p(n){return f.mass=n,g}var g={direction:d,location:e,seek:function(n){l.set(n).subtract(e);var t,r,o,i,a,s=l.get(),m=(t=s,r=0,o=100,i=0,a=f.speed,i+(t-r)/(o-r)*(a-i));return d.set(l),l.normalize().multiply(m).subtract(c),function(n){n.divide(f.mass),u.add(n)}(l),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)},useDefaultMass:function(){return p(i),g},useDefaultSpeed:function(){return m(t),g},useMass:p,useSpeed:m};return g}function p(n){var e=n.limit,t=n.location,r=n.scrollBody,o=n.animation,i=e.min,a=e.max,c=e.reachedMin,u=e.reachedMax,s=!1,l=0;return{constrain:function(n){(function(n){return!s&&!l&&(c(t.get())?n.get()!==i:!!u(t.get())&&n.get()!==a)})(n)&&(l=window.setTimeout((function(){var t=e.constrain(n.get());n.set(t),r.useSpeed(10).useMass(3),o.start(),l=0}),50))},toggleActive:function(n){s=!n}}}function g(n){var e=n.alignment,t=n.contentSize,r=n.viewSize,o=a({min:-t+r,max:0}),i=[e.measure(t)],c=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 a({min:n.lastIndexOf(e)+1,max:n.indexOf(t)})}(t),u=r.min,s=r.max;return c?e?t.slice(u-1,s+1):t:i}}}function v(n){var e=n.contentSize,t=n.location,r=n.limit,o=n.pxToPercent,i=a({min:r.min+o.measure(.1),max:r.max+o.measure(.1)}),c=i.reachedMin,u=i.reachedMax;return{loop:function(n,r){if(function(n){return 1===n?u(t.get()):-1===n&&c(t.get())}(r)){var o=e*(-1*r);n.forEach((function(n){return n.add(o)}))}}}}function x(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 h(n){var e,t=n.axis,r=n.location,o=n.slidesInView,i=n.contentSize,a=n.viewSize,c=n.slideSizes,u=n.scrollSnaps,s=l(c),d=l(c).reverse(),f=(e=u[0]-1,v(g(d,e),"end")).concat(function(){var n=a-u[0]-1;return v(g(s,n),"start")}()),m="x"===t.scroll?"left":"top";function p(n,e){return n.reduce((function(n,e){return n-c[e]}),e)}function g(n,e){return n.reduce((function(n,t){return p(n,e)>0?n.concat([t]):n}),[])}function v(n,e){var t="start"===e,a=t?-i:i,c=o.findSlideBounds(a);return n.map((function(n){var e=t?0:-i,o=t?i:0,a=c.filter((function(e){return e.index===n}))[0][t?"end":"start"];return{point:a,getTarget:function(){return r.get()>a?e:o},index:n,location:-1}}))}return{canLoop:function(){return f.every((function(n){var e=n.index;return p(s.filter((function(n){return n!==e})),a)<=0}))},clear:function(n){f.forEach((function(e){var t=e.index;n[t].style[m]=""}))},loop:function(n){f.forEach((function(e){var t=e.getTarget,r=e.location,o=e.index,i=t();i!==r&&(n[o].style[m]=i+"%",e.location=i)}))},loopPoints:f}}function S(n){var e=n.scrollTo,t=n.slidesToScroll,r=n.root,o=i(),a=o.removeAll,c=0;function u(n){9===n.keyCode&&(c=(new Date).getTime())}function s(n,i){o.add(n,"focus",(function(){if(!((new Date).getTime()-c>10)){r.scrollLeft=0;var n=Math.floor(i/t);e.index(n,0)}}),!0)}return{addActivationEvents:function(n){o.add(document,"keydown",u,!1),n.forEach(s)},removeAllEvents:a}}function w(n){var e=n.axis,t=n.container,r={x:function(n){return"translate3d("+n+"%,0px,0px)"},y:function(n){return"translate3d(0px,"+n+"%,0px)"}}[e.scroll],o=s(2),i=t.style,a=!1,c=0;return{clear:function(){i.transform="",c=0},to:function(n){if(!a){var e=o(n.get());c!==e&&(getComputedStyle(t).transform,i.transform=r(e),c=e)}},toggleActive:function(n){a=!n}}}function y(n,o,i,s,d){var f,y,b,T,M,z=s.align,A=s.axis,D=s.startIndex,E=s.inViewThreshold,P=s.loop,I=s.speed,B=s.dragFree,C=s.slidesToScroll,L=s.containScroll,k=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),O=(f=k.measure(o),{measure:function(n){return n/f*100},totalPercent:100}),V=O.totalPercent,F=i.map(k.measure).map(O.measure),N=l(F),U=function(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}(F,C).map((function(n){return n.reduce((function(n,e){return n+e}))})),j=F.reduce((function(n,e){return n+e}),0),H=e({align:z,viewSize:V}),q=function(n){var e,r=n.snapSizes,o=n.alignment,i=n.loop,c=r.map(o.measure),u=(e=t({limit:a({min:0,max:r.length-1}),start:0,loop:i}),r.map((function(n,t){var r=e.set(t+1).get();return n+c[t]-c[r]})));return{measure:function(n){return u.slice(0,n).reduce((function(n,e){return n-e}),c[0])}}}({snapSizes:U,alignment:H,loop:P}),R=l(U).map(q.measure),X=g({alignment:H,contentSize:j,viewSize:V}),G=!P&&""!==L,Y="trimSnaps"===L,J=X.measure(R,Y),K=G?J:R,Q=t({limit:a({min:0,max:Math.max(0,K.length-1)}),start:D,loop:P}),W=Q.clone(),Z=function(n){var e=n.contentSize,t=n.loop;return{measure:function(n){var r=n[0],o=n[n.length-1];return a({min:t?r-e:o,max:r})}}}({loop:P,contentSize:j}).measure(K),$=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(){sn.scrollBody.seek(en).update();var n=sn.scrollBody.settle(en);if(un.pointerDown()||(P||sn.scrollBounds.constrain(en),n&&(sn.animation.stop(),d.emit("settle"))),P){var e=sn.scrollBody.direction.get();sn.scrollLooper.loop(tn,e),sn.slideLooper.loop(i)}n||d.emit("scroll"),sn.translate.to(sn.scrollBody.location),sn.animation.proceed()})),_=K[Q.get()],nn=r(_),en=r(_),tn=[nn,en],rn=m({location:nn,speed:I,mass:1}),on=x({contentSize:j,index:Q,limit:Z,loop:P,scrollSnaps:K,target:en}),an=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:$,events:d,index:Q,indexPrevious:W,scrollTarget:on,target:en}),cn=function(n){var e=n.contentSize,t=n.slideSizes,r=n.viewSize,o=n.inViewThreshold,i=n.loop,a=Math.min(Math.max(o,.01),.99),c=l(t).map((function(n){return t.slice(0,n).reduce((function(n,e){return n-e}),0)})),u=(i?[0,e,-e]:[0]).reduce((function(n,e){return n.concat(s(e,a))}),[]);function s(n,e){var o=t.map((function(n){return n*(e||0)}));return c.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 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:s}}({contentSize:j,inViewThreshold:E,loop:P,slideSizes:F,viewSize:V}),un=c({animation:$,axis:k,dragFree:B,dragTracker:u({axis:k,pxToPercent:O}),element:n,events:d,index:Q,limit:Z,location:nn,loop:P,scrollBody:rn,scrollTo:an,scrollTarget:on,target:en}),sn={animation:$,axis:k,dragHandler:un,pxToPercent:O,index:Q,indexPrevious:W,limit:Z,location:nn,options:s,scrollBody:rn,scrollBounds:p({animation:$,limit:Z,location:nn,scrollBody:rn}),scrollLooper:v({contentSize:j,limit:Z,location:nn,pxToPercent:O}),scrollProgress:(y={limit:Z},b=y.limit,T=b.max,M=b.length,{get:function(n){return(n-T)/-M}}),scrollSnaps:K,scrollTarget:on,scrollTo:an,slideFocus:S({root:n,scrollTo:an,slidesToScroll:C}),slideLooper:h({axis:k,contentSize:j,location:nn,scrollSnaps:K,slideSizes:F,slidesInView:cn,viewSize:V}),slidesInView:cn,slideIndexes:N,target:en,translate:w({axis:k,container:o})};return sn}var b={align:"center",axis:"x",containScroll:"",containerSelector:"*",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,a,c,u,s,l=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=i(),p=(r=function(){if(h){var n=c.axis.measure(e);w!==n&&E(),l.emit("resize")}},o=500,a={id:0},function(){window.clearTimeout(a.id),a.id=window.setTimeout(r,o)||0}),g=E,v=l.on,x=l.off,h=!1,S=n({},b),w=0;function T(){if(!e)throw new Error("Missing root node 😢");var n,t=S.containerSelector,r=e.querySelector(t);if(!r)throw new Error("Missing container node 😢");n=(u=r).children,s=Array.prototype.slice.call(n)}function M(t){if(T(),S=n(S,t),c=y(e,u,s,S,l),w=c.axis.measure(e),m.add(window,"resize",p),c.translate.to(c.scrollBody.location),S.loop){if(!c.slideLooper.canLoop())return D(),M({loop:!1});c.slideLooper.loop(s)}S.draggable&&s.length&&(c.dragHandler.addActivationEvents(),S.draggableClass&&f(e,S.draggableClass),S.draggingClass&&l.on("pointerDown",z).on("pointerUp",z)),s.length&&c.slideFocus.addActivationEvents(s),S.selectedClass&&(A(),l.on("select",A).on("pointerUp",A)),h||(setTimeout((function(){return l.emit("init")}),0),h=!0)}function z(n){var t=S.draggingClass;"pointerDown"===n?f(e,t):d(e,t)}function A(){var n=S.selectedClass,e=P(!0);I(!0).forEach((function(e){return d(s[e],n)})),e.forEach((function(e){return f(s[e],n)}))}function D(){c.dragHandler.removeAllEvents(),c.slideFocus.removeAllEvents(),c.animation.stop(),m.removeAll(),c.translate.clear(),c.slideLooper.clear(s),d(e,S.draggableClass),s.forEach((function(n){return d(n,S.selectedClass)})),l.off("select",A),l.off("pointerUp",A),l.off("pointerDown",z),l.off("pointerUp",z)}function E(e){if(h){var t=n({startIndex:C()},e);D(),M(t),l.emit("reInit")}}function P(n){var e=c[n?"target":"location"].get(),t=S.loop?"removeOffset":"constrain";return c.slidesInView.check(c.limit[t](e))}function I(n){var e=P(n);return c.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}function B(n,e){c.scrollBody.useDefaultMass().useDefaultSpeed(),h&&c.scrollTo.index(n,e||0)}function C(){return c.index.get()}return M(t),{canScrollNext:function(){return c.index.clone().add(1).get()!==C()},canScrollPrev:function(){return c.index.clone().add(-1).get()!==C()},clickAllowed:function(){return c.dragHandler.clickAllowed()},containerNode:function(){return u},dangerouslyGetEngine:function(){return c},destroy:function(){h&&(D(),h=!1,l.emit("destroy"))},off:x,on:v,previousScrollSnap:function(){return c.indexPrevious.get()},reInit:g,scrollNext:function(){B(c.index.clone().add(1).get(),-1)},scrollPrev:function(){B(c.index.clone().add(-1).get(),1)},scrollProgress:function(){return c.scrollProgress.get(c.location.get())},scrollSnapList:function(){return c.scrollSnaps.map(c.scrollProgress.get)},scrollTo:B,selectedScrollSnap:C,slideNodes:function(){return s},slidesInView:P,slidesNotInView:I}}})); | ||
!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){var e=n.start,r=n.limit,o=n.loop,i=r.min,a=r.max,c=r[o?"loop":"constrain"],u=c(e);function s(){return u}function l(n){return u=c(n),d}var d={add:function n(e){if(0!==e){var t=e/Math.abs(e);return l(s()+t),n(e+-1*t)}return d},clone:function(){return t({start:s(),limit:r,loop:o})},get:s,max:a,min:i,set:l};return d}function r(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 o(n){var e=r(t(n));function t(n){return 0===n?0:n/Math.abs(n)}var o={get:e.get,set:function(n){var r=t(n.get());return 0!==r&&e.set(r),o}};return o}function i(){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 a(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 c(n){var e=n.target,t=n.scrollBody,c=n.dragFree,u=n.animation,s=n.axis,l=n.element,d=n.dragTracker,f=n.location,m=n.events,p=n.limit,g=s.scroll,v=s.cross,x=["INPUT","SELECT","TEXTAREA"],h=r(0),S=r(0),w=r(0),y=i(),b=i(),T={mouse:2.5,touch:3.5},M={mouse:5,touch:7},z=c?5:12,A=a({min:p.min-70,max:p.max+70}),D=!1,E=!1,P=!1,I=!1;function B(n){if(!(I="mousedown"===n.type)||0===n.button){var r,o,i=k(e.get(),f.get())>=2,a=I||!i,c=(r=n.target,o=r.nodeName||"",!(x.indexOf(o)>-1)),u=i||I&&c;D=!0,d.pointerDown(n),w.set(e),e.set(f),t.useDefaultMass().useSpeed(80),function(){var n=I?document:l;b.add(n,"touchmove",C).add(n,"touchend",L).add(n,"mousemove",C).add(n,"mouseup",L)}(),h.set(d.readPoint(n,g)),S.set(d.readPoint(n,v)),m.emit("pointerDown"),a&&(P=!1),u&&n.preventDefault()}}function C(t){if(!E&&!I){if(!t.cancelable)return L();var r=d.readPoint(t,g).get(),o=d.readPoint(t,v).get(),i=k(r,h.get()),a=k(o,S.get());if(!(E=i>a)&&!P)return L()}var c=d.pointerMove(t),s=p.reachedAny(f.get()),l=!n.loop&&s?2:1;!P&&c&&(P=!0),u.start(),e.add(c/l),t.preventDefault()}function L(){var r,i,a,u=n.scrollTo,s=d.pointerUp()*(c?M:T)[I?"mouse":"touch"],l=function(t){var r=n.scrollTarget,i=n.index,a=!(r.byDistance(0,!1).index!==i.get())&&Math.abs(t)>4,u=t+f.get();if(a&&!c&&!p.reachedAny(u)){var s=i.clone().add(-1*o(t).get());return r.byIndex(s.get(),0).distance}if(!n.loop&&A.reachedAny(u)){var l=A.reachedMax(u)?"max":"min";return A[l]-e.get()}return r.byDistance(t,!c).distance}(s),g=(r=s,i=l,a=k(Math.abs(r),Math.abs(i)),Math.abs(r)<=Math.abs(i)||0===r||0===i?0:Math.abs(a/r));k(e.get(),w.get())>=.5&&!I&&(P=!0),E=!1,D=!1,b.removeAll(),t.useSpeed(z+z*g),u.distance(l,!c),I=!1,m.emit("pointerUp")}function k(n,e){return Math.abs(n-e)}function O(n){P&&n.preventDefault()}return{addActivationEvents:function(){var n=l;y.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",B).add(n,"mousedown",B).add(n,"touchcancel",L).add(n,"contextmenu",L).add(n,"click",O)},clickAllowed:function(){return!P},pointerDown:function(){return D},removeAllEvents:function(){y.removeAll(),b.removeAll()}}}function u(n){var e=n.axis,t=n.pxToPercent,o=e.scroll,i={x:"clientX",y:"clientY"},a=r(0),c=r(0),u=r(0),s=r(0),l=[],d=(new Date).getTime(),f=!1;function m(n,e){f=!n.touches;var t=i[e],r=f?n[t]:n.touches[0][t];return s.set(r)}return{pointerDown:function(n){var e=m(n,o);return a.set(e),u.set(e),t.measure(a.get())},pointerMove:function(n){var e=m(n,o),r=(new Date).getTime(),i=r-d;return i>=10&&(i>=100&&(l=[]),l.push(e.get()),d=r),c.set(e).subtract(u),u.set(e),t.measure(c.get())},pointerUp:function(){var n=(new Date).getTime()-d,e=u.get(),r=l.slice(-5).map((function(n){return e-n})).sort((function(n,e){return Math.abs(n)<Math.abs(e)?1:-1}))[0];return u.set(n>100||!r?0:r),l=[],t.measure(u.get())},readPoint:m}}function s(n){var e=Math.pow(10,n);return function(n){return Math.round(n*e)/e}}function l(n){return Object.keys(n).map(Number)}function d(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 m(n){var e=n.location,t=n.speed,i=n.mass,a=s(2),c=r(0),u=r(0),l=r(0),d=o(0),f={speed:t,mass:i};function m(n){return f.speed=n,g}function p(n){return f.mass=n,g}var g={direction:d,location:e,seek:function(n){l.set(n).subtract(e);var t,r,o,i,a,s=l.get(),m=(t=s,r=0,o=100,i=0,a=f.speed,i+(t-r)/(o-r)*(a-i));return d.set(l),l.normalize().multiply(m).subtract(c),function(n){n.divide(f.mass),u.add(n)}(l),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)},useDefaultMass:function(){return p(i),g},useDefaultSpeed:function(){return m(t),g},useMass:p,useSpeed:m};return g}function p(n){var e=n.limit,t=n.location,r=n.scrollBody,o=n.animation,i=e.min,a=e.max,c=e.reachedMin,u=e.reachedMax,s=!1,l=0;return{constrain:function(n){(function(n){return!s&&!l&&(c(t.get())?n.get()!==i:!!u(t.get())&&n.get()!==a)})(n)&&(l=window.setTimeout((function(){var t=e.constrain(n.get());n.set(t),r.useSpeed(10).useMass(3),o.start(),l=0}),50))},toggleActive:function(n){s=!n}}}function g(n){var e=n.alignment,t=n.contentSize,r=n.viewSize,o=a({min:-t+r,max:0}),i=[e.measure(t)],c=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 a({min:n.lastIndexOf(e)+1,max:n.indexOf(t)})}(t),u=r.min,s=r.max;return c?e?t.slice(u-1,s+1):t:i}}}function v(n){var e=n.contentSize,t=n.location,r=n.limit,o=n.pxToPercent,i=a({min:r.min+o.measure(.1),max:r.max+o.measure(.1)}),c=i.reachedMin,u=i.reachedMax;return{loop:function(n,r){if(function(n){return 1===n?u(t.get()):-1===n&&c(t.get())}(r)){var o=e*(-1*r);n.forEach((function(n){return n.add(o)}))}}}}function x(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 h(n){var e,t=n.axis,r=n.location,o=n.slidesInView,i=n.contentSize,a=n.viewSize,c=n.slideSizes,u=n.scrollSnaps,s=l(c),d=l(c).reverse(),f=(e=u[0]-1,v(g(d,e),"end")).concat(function(){var n=a-u[0]-1;return v(g(s,n),"start")}()),m="x"===t.scroll?"left":"top";function p(n,e){return n.reduce((function(n,e){return n-c[e]}),e)}function g(n,e){return n.reduce((function(n,t){return p(n,e)>0?n.concat([t]):n}),[])}function v(n,e){var t="start"===e,a=t?-i:i,c=o.findSlideBounds(a);return n.map((function(n){var e=t?0:-i,o=t?i:0,a=c.filter((function(e){return e.index===n}))[0][t?"end":"start"];return{point:a,getTarget:function(){return r.get()>a?e:o},index:n,location:-1}}))}return{canLoop:function(){return f.every((function(n){var e=n.index;return p(s.filter((function(n){return n!==e})),a)<=0}))},clear:function(n){f.forEach((function(e){var t=e.index;n[t].style[m]=""}))},loop:function(n){f.forEach((function(e){var t=e.getTarget,r=e.location,o=e.index,i=t();i!==r&&(n[o].style[m]=i+"%",e.location=i)}))},loopPoints:f}}function S(n){var e=n.scrollTo,t=n.slidesToScroll,r=n.root,o=i(),a=o.removeAll,c=0;function u(n){9===n.keyCode&&(c=(new Date).getTime())}function s(n,i){o.add(n,"focus",(function(){if(!((new Date).getTime()-c>10)){r.scrollLeft=0;var n=Math.floor(i/t);e.index(n,0)}}),!0)}return{addActivationEvents:function(n){o.add(document,"keydown",u,!1),n.forEach(s)},removeAllEvents:a}}function w(n){var e=n.axis,t=n.container,r={x:function(n){return"translate3d("+n+"%,0px,0px)"},y:function(n){return"translate3d(0px,"+n+"%,0px)"}}[e.scroll],o=s(2),i=t.style,a=!1,c=0;return{clear:function(){i.transform="",c=0},to:function(n){if(!a){var e=o(n.get());c!==e&&(getComputedStyle(t).transform,i.transform=r(e),c=e)}},toggleActive:function(n){a=!n}}}function y(n,o,i,s,d){var f,y,b,T,M,z=s.align,A=s.axis,D=s.startIndex,E=s.inViewThreshold,P=s.loop,I=s.speed,B=s.dragFree,C=s.slidesToScroll,L=s.containScroll,k=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),O=(f=k.measure(o),{measure:function(n){return n/f*100},totalPercent:100}),V=O.totalPercent,F=i.map(k.measure).map(O.measure),N=l(F),U=function(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}(F,C).map((function(n){return n.reduce((function(n,e){return n+e}))})),j=F.reduce((function(n,e){return n+e}),0),H=e({align:z,viewSize:V}),q=function(n){var e,r=n.snapSizes,o=n.alignment,i=n.loop,c=r.map(o.measure),u=(e=t({limit:a({min:0,max:r.length-1}),start:0,loop:i}),r.map((function(n,t){var r=e.set(t+1).get();return n+c[t]-c[r]})));return{measure:function(n){return u.slice(0,n).reduce((function(n,e){return n-e}),c[0])}}}({snapSizes:U,alignment:H,loop:P}),R=l(U).map(q.measure),X=g({alignment:H,contentSize:j,viewSize:V}),G=!P&&""!==L,Y="trimSnaps"===L,J=X.measure(R,Y),K=G?J:R,Q=t({limit:a({min:0,max:Math.max(0,K.length-1)}),start:D,loop:P}),W=Q.clone(),Z=function(n){var e=n.contentSize,t=n.loop;return{measure:function(n){var r=n[0],o=n[n.length-1];return a({min:t?r-e:o,max:r})}}}({loop:P,contentSize:j}).measure(K),$=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(){sn.scrollBody.seek(en).update();var n=sn.scrollBody.settle(en);if(un.pointerDown()||(P||sn.scrollBounds.constrain(en),n&&(sn.animation.stop(),d.emit("settle"))),P){var e=sn.scrollBody.direction.get();sn.scrollLooper.loop(tn,e),sn.slideLooper.loop(i)}n||d.emit("scroll"),sn.translate.to(sn.scrollBody.location),sn.animation.proceed()})),_=K[Q.get()],nn=r(_),en=r(_),tn=[nn,en],rn=m({location:nn,speed:I,mass:1}),on=x({contentSize:j,index:Q,limit:Z,loop:P,scrollSnaps:K,target:en}),an=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:$,events:d,index:Q,indexPrevious:W,scrollTarget:on,target:en}),cn=function(n){var e=n.contentSize,t=n.slideSizes,r=n.viewSize,o=n.inViewThreshold,i=n.loop,a=Math.min(Math.max(o,.01),.99),c=l(t).map((function(n){return t.slice(0,n).reduce((function(n,e){return n-e}),0)})),u=(i?[0,e,-e]:[0]).reduce((function(n,e){return n.concat(s(e,a))}),[]);function s(n,e){var o=t.map((function(n){return n*(e||0)}));return c.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 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:s}}({contentSize:j,inViewThreshold:E,loop:P,slideSizes:F,viewSize:V}),un=c({animation:$,axis:k,dragFree:B,dragTracker:u({axis:k,pxToPercent:O}),element:n,events:d,index:Q,limit:Z,location:nn,loop:P,scrollBody:rn,scrollTo:an,scrollTarget:on,target:en}),sn={animation:$,axis:k,dragHandler:un,pxToPercent:O,index:Q,indexPrevious:W,limit:Z,location:nn,options:s,scrollBody:rn,scrollBounds:p({animation:$,limit:Z,location:nn,scrollBody:rn}),scrollLooper:v({contentSize:j,limit:Z,location:nn,pxToPercent:O}),scrollProgress:(y={limit:Z},b=y.limit,T=b.max,M=b.length,{get:function(n){return(n-T)/-M}}),scrollSnaps:K,scrollTarget:on,scrollTo:an,slideFocus:S({root:n,scrollTo:an,slidesToScroll:C}),slideLooper:h({axis:k,contentSize:j,location:nn,scrollSnaps:K,slideSizes:F,slidesInView:cn,viewSize:V}),slidesInView:cn,slideIndexes:N,target:en,translate:w({axis:k,container:o})};return sn}var b={align:"center",axis:"x",containScroll:"",containerSelector:"*",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,a,c,u,s,l=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=i(),p=(r=function(){if(h){var n=c.axis.measure(e);w!==n&&E(),l.emit("resize")}},o=500,a={id:0},function(){window.clearTimeout(a.id),a.id=window.setTimeout(r,o)||0}),g=E,v=l.on,x=l.off,h=!1,S=n({},b),w=0;function T(){if(!e)throw new Error("Missing root node 😢");var n,t=S.containerSelector,r=e.querySelector(t);if(!r)throw new Error("Missing container node 😢");n=(u=r).children,s=Array.prototype.slice.call(n)}function M(t){if(T(),S=n(S,t),c=y(e,u,s,S,l),w=c.axis.measure(e),m.add(window,"resize",p),c.translate.to(c.scrollBody.location),S.loop){if(!c.slideLooper.canLoop())return D(),M({loop:!1});c.slideLooper.loop(s)}S.draggable&&s.length&&(c.dragHandler.addActivationEvents(),S.draggableClass&&f(e,S.draggableClass),S.draggingClass&&l.on("pointerDown",z).on("pointerUp",z)),s.length&&c.slideFocus.addActivationEvents(s),S.selectedClass&&(A(),l.on("select",A).on("pointerUp",A)),h||(setTimeout((function(){return l.emit("init")}),0),h=!0)}function z(n){var t=S.draggingClass;"pointerDown"===n?f(e,t):d(e,t)}function A(){var n=S.selectedClass,e=P(!0);I(!0).forEach((function(e){return d(s[e],n)})),e.forEach((function(e){return f(s[e],n)}))}function D(){c.dragHandler.removeAllEvents(),c.slideFocus.removeAllEvents(),c.animation.stop(),m.removeAll(),c.translate.clear(),c.slideLooper.clear(s),d(e,S.draggableClass),s.forEach((function(n){return d(n,S.selectedClass)})),l.off("select",A),l.off("pointerUp",A),l.off("pointerDown",z),l.off("pointerUp",z)}function E(e){if(h){var t=n({startIndex:C()},e);D(),M(t),l.emit("reInit")}}function P(n){var e=c[n?"target":"location"].get(),t=S.loop?"removeOffset":"constrain";return c.slidesInView.check(c.limit[t](e))}function I(n){var e=P(n);return c.slideIndexes.filter((function(n){return-1===e.indexOf(n)}))}function B(n,e){c.scrollBody.useDefaultMass().useDefaultSpeed(),h&&c.scrollTo.index(n,e||0)}function C(){return c.index.get()}return M(t),{canScrollNext:function(){return c.index.clone().add(1).get()!==C()},canScrollPrev:function(){return c.index.clone().add(-1).get()!==C()},clickAllowed:function(){return c.dragHandler.clickAllowed()},containerNode:function(){return u},dangerouslyGetEngine:function(){return c},destroy:function(){h&&(D(),h=!1,l.emit("destroy"))},off:x,on:v,previousScrollSnap:function(){return c.indexPrevious.get()},reInit:g,scrollNext:function(){B(c.index.clone().add(1).get(),-1)},scrollPrev:function(){B(c.index.clone().add(-1).get(),1)},scrollProgress:function(){return c.scrollProgress.get(c.location.get())},scrollSnapList:function(){return c.scrollSnaps.map(c.scrollProgress.get)},scrollTo:B,selectedScrollSnap:C,slideNodes:function(){return s},slidesInView:P,slidesNotInView:I}}})); |
{ | ||
"name": "embla-carousel", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "author": "David Cetinkaya <david.o.cetinkaya@gmail.com>", |
@@ -607,7 +607,7 @@ import { useState, useRef, useMemo, useEffect } from 'react'; | ||
var cl = node.classList; | ||
if (cl.contains(className)) cl.remove(className); | ||
if (className && cl.contains(className)) cl.remove(className); | ||
} | ||
function addClass(node, className) { | ||
var cl = node.classList; | ||
if (!cl.contains(className)) cl.add(className); | ||
if (className && !cl.contains(className)) cl.add(className); | ||
} | ||
@@ -614,0 +614,0 @@ |
@@ -611,7 +611,7 @@ 'use strict'; | ||
var cl = node.classList; | ||
if (cl.contains(className)) cl.remove(className); | ||
if (className && cl.contains(className)) cl.remove(className); | ||
} | ||
function addClass(node, className) { | ||
var cl = node.classList; | ||
if (!cl.contains(className)) cl.add(className); | ||
if (className && !cl.contains(className)) cl.add(className); | ||
} | ||
@@ -618,0 +618,0 @@ |
@@ -92,2 +92,3 @@ <br /> | ||
<a href="https://github.com/wopian"><img src="https://avatars3.githubusercontent.com/u/3440094?s=122&v=4" title="wopian" width="66" height="66" style="max-width:100%;"></a> | ||
<a href="https://github.com/msallent"><img src="https://avatars3.githubusercontent.com/u/8879212?s=122&v=4" title="msallent" width="66" height="66" style="max-width:100%;"></a> | ||
</p> | ||
@@ -94,0 +95,0 @@ </div> |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
655475
129