embla-carousel-react
Advanced tools
Comparing version 8.0.0-rc10 to 8.0.0-rc11
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselReact=t(n.React)}(this,(function(n){"use strict";function t(n){return function(n){return"[object Object]"===Object.prototype.toString.call(n)}(n)||Array.isArray(n)}function e(n,r){const o=Object.keys(n),i=Object.keys(r);if(o.length!==i.length)return!1;return JSON.stringify(Object.keys(n.breakpoints||{}))===JSON.stringify(Object.keys(r.breakpoints||{}))&&o.every((o=>{const i=n[o],c=r[o];return"function"==typeof i?`${i}`==`${c}`:t(i)&&t(c)?e(i,c):i===c}))}function r(n){return n.concat().sort(((n,t)=>n.name>t.name?1:-1)).map((n=>n.options))}function o(n){return"number"==typeof n}function i(n){return"string"==typeof n}function c(n){return"boolean"==typeof n}function u(n){return"[object Object]"===Object.prototype.toString.call(n)}function s(n){return Math.abs(n)}function a(n){return Math.sign(n)}function d(n,t){return s(n-t)}function l(n){return m(n).map(Number)}function f(n){return n[p(n)]}function p(n){return Math.max(0,n.length-1)}function m(n){return Object.keys(n)}function g(n,t){return[n,t].reduce(((n,t)=>(m(t).forEach((e=>{const r=n[e],o=t[e],i=u(r)&&u(o);n[e]=i?g(r,o):o})),n)),{})}function h(n,t){return void 0!==t.MouseEvent&&n instanceof t.MouseEvent}function y(n,t){const e={start:function(){return 0},center:function(n){return r(n)/2},end:r};function r(n){return t-n}return{measure:function(r){return o(n)?t*Number(n):e[n](r)}}}function x(n,t){const e=s(n-t);function r(t){return t<n}function o(n){return n>t}function i(n){return r(n)||o(n)}return{length:e,max:t,min:n,constrain:function(e){return i(e)?r(e)?n:t:e},reachedAny:i,reachedMax:o,reachedMin:r,removeOffset:function(n){return e?n-e*Math.ceil((n-t)/e):n}}}function b(n,t,e){const{constrain:r}=x(0,n),o=n+1;let i=c(t);function c(n){return e?s((o+n)%o):r(n)}function u(){return i}function a(){return b(n,u(),e)}const d={get:u,set:function(n){return i=c(n),d},add:function(n){return a().set(u()+n)},clone:a};return d}function v(){let n=[];const t={add:function(e,r,o,i={passive:!0}){return e.addEventListener(r,o,i),n.push((()=>e.removeEventListener(r,o,i))),t},clear:function(){n=n.filter((n=>n()))}};return t}function S(n,t,e,r,o,i,u,l,f,p,m,g,y,b,S,w,E,O,D){const{cross:A}=n,k=["INPUT","SELECT","TEXTAREA"],M={passive:!1},I=v(),L=v(),P=x(50,225).constrain(S.measure(20)),T={mouse:300,touch:400},F={mouse:500,touch:600},z=w?43:25;let B=!1,R=0,j=0,H=!1,N=!1,C=!1,V=!1;function q(n){const e=u.readPoint(n),r=u.readPoint(n,A),o=d(e,R),c=d(r,j);if(!N&&!V){if(!n.cancelable)return $(n);if(N=o>c,!N)return $(n)}const s=u.pointerMove(n),a=t.apply(s);o>E&&(C=!0),m.useFriction(.3).useDuration(1),a&&m.useDirection(a),f.start(),i.add(a),n.preventDefault()}function $(n){const e=g.byDistance(0,!1).index!==y.get(),r=u.pointerUp(n)*(w?F:T)[V?"mouse":"touch"],o=function(n,t){const e=y.add(-1*a(n)),r=g.byDistance(n,!w).distance;return w||s(n)<P?r:O&&t?.5*r:g.byIndex(e.get(),0).distance}(t.apply(r),e),i=function(n,t){if(0===n||0===t)return 0;if(s(n)<=s(t))return 0;const e=d(s(n),s(t));return s(e/n)}(r,o),c=z-10*i,l=D+i/50;N=!1,H=!1,L.clear(),m.useDuration(c).useFriction(l),p.distance(o,!w),V=!1,b.emit("pointerUp")}function U(n){C&&(n.stopPropagation(),n.preventDefault())}return{init:function(n,t){if(!t)return;function s(s){(c(t)||t(n,s))&&function(n){const t=h(n,o);if(V=t,t&&0!==n.button)return;if(function(n){const t=n.nodeName||"";return k.includes(t)}(n.target))return;C=w&&t&&!n.buttons&&B,B=d(i.get(),l.get())>=2,H=!0,u.pointerDown(n),m.useFriction(0).useDuration(0),i.set(l),function(){const n=V?r:e;L.add(n,"touchmove",q,M).add(n,"touchend",$).add(n,"mousemove",q,M).add(n,"mouseup",$)}(),R=u.readPoint(n),j=u.readPoint(n,A),b.emit("pointerDown")}(s)}const a=e;I.add(a,"dragstart",(n=>n.preventDefault()),M).add(a,"touchmove",(()=>{}),M).add(a,"touchend",(()=>{})).add(a,"touchstart",s).add(a,"mousedown",s).add(a,"touchcancel",$).add(a,"contextmenu",$).add(a,"click",U,!0)},pointerDown:function(){return H},destroy:function(){I.clear(),L.clear()}}}function w(n,t){let e,r;function o(n){return n.timeStamp}function i(e,r){const o="client"+("x"===(r||n.scroll)?"X":"Y");return(h(e,t)?e:e.touches[0])[o]}return{pointerDown:function(n){return e=n,r=n,i(n)},pointerMove:function(n){const t=i(n)-i(r),c=o(n)-o(e)>170;return r=n,c&&(e=n),t},pointerUp:function(n){if(!e||!r)return 0;const t=i(r)-i(e),c=o(n)-o(e),u=o(n)-o(r)>170,a=t/c;return c&&!u&&s(a)>.1?a:0},readPoint:i}}function E(n,t,e,r,o){let i,u,s=[],a=!1;function d(n){return o.measureSize(n.getBoundingClientRect())}return{init:function(o,l){if(!l)return;u=d(n),s=r.map(d),i=new ResizeObserver((i=>{a||(c(l)||l(o,i))&&function(i){for(const c of i){const i=c.target===n,a=r.indexOf(c.target);if((i?u:s[a])!==d(i?n:r[a])){e.requestAnimationFrame((()=>{o.reInit(),t.emit("resize")}));break}}}(i)})),[n].concat(r).forEach((n=>i.observe(n)))},destroy:function(){i&&i.disconnect(),a=!0}}}function O(n,t,e,r,o){const i=o.measure(10),c=o.measure(50),u=x(.1,.99);let a=!1;return{constrain:function(o){if(a||!n.reachedAny(e.get())||!n.reachedAny(t.get()))return;const d=n.reachedMin(t.get())?"min":"max",l=s(n[d]-t.get()),f=e.get()-t.get(),p=u.constrain(l/c);e.subtract(f*p),!o&&s(f)<i&&(e.set(n.constrain(e.get())),r.useDuration(25).useBaseFriction())},toggleActive:function(n){a=!n}}}function D(n,t,e,r){const o=x(-t+n,e[0]),i=e.map(o.constrain).map((n=>parseFloat(n.toFixed(3))));return{snapsContained:function(){if(t<=n)return[o.max];if("keepSnaps"===r)return i;const{min:e,max:c}=function(){const n=i[0],t=f(i),e=i.lastIndexOf(n),r=i.indexOf(t)+1;return x(e,r)}();return i.slice(e,c)}()}}function A(n,t,e,r){const o=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:u}=x(o,i);return{loop:function(t){if(!function(n){return 1===n?u(e.get()):-1===n&&c(e.get())}(t))return;const o=n*(-1*t);r.forEach((n=>n.add(o)))}}}function k(n){const{max:t,length:e}=n;return{get:function(n){return(n-t)/-e}}}function M(n,t,e,r,o){const{reachedAny:i,removeOffset:c,constrain:u}=r;function d(n){return n.concat().sort(((n,t)=>s(n)-s(t)))[0]}function l(t,r){const o=[t,t+e,t-e];if(!n)return o[0];if(!r)return d(o);return d(o.filter((n=>a(n)===r)))}return{byDistance:function(e,r){const a=o.get()+e,{index:d,distance:f}=function(e){const r=n?c(e):u(e),o=t.map((n=>n-r)).map((n=>l(n,0))).map(((n,t)=>({diff:n,index:t}))).sort(((n,t)=>s(n.diff)-s(t.diff))),{index:i}=o[0];return{index:i,distance:r}}(a),p=!n&&i(a);return!r||p?{index:d,distance:e}:{index:d,distance:e+l(t[d]-f,0)}},byIndex:function(n,e){return{index:n,distance:l(t[n]-o.get(),e)}},shortcut:l}}function I(n){let t=n;function e(n){return o(n)?n:n.get()}return{get:function(){return t},set:function(n){t=e(n)},add:function(n){t+=e(n)},subtract:function(n){t-=e(n)}}}function L(n,t,e){const r="x"===n.scroll?function(n){return`translate3d(${n}px,0px,0px)`}:function(n){return`translate3d(0px,${n}px,0px)`},o=e.style;let i=!1;return{clear:function(){i||(o.transform="",e.getAttribute("style")||e.removeAttribute("style"))},to:function(n){i||(o.transform=r(t.apply(n)))},toggleActive:function(n){i=!n}}}function P(n,t,e,r,o,i,c,u,s){const a=l(o),d=l(o).reverse(),f=function(){const n=i[0]-1;return g(m(d,n),"end")}().concat(function(){const n=e-i[0]-1;return g(m(a,n),"start")}());function p(n,t){return n.reduce(((n,t)=>n-o[t]),t)}function m(n,t){return n.reduce(((n,e)=>p(n,t)>0?n.concat([e]):n),[])}function g(e,o){const i="start"===o,a=i?-r:r,d=c.findSlideBounds([a]);return e.map((e=>{const o=i?0:-r,c=i?r:0,a=d.filter((n=>n.index===e))[0][i?"end":"start"];return{index:e,slideLocation:I(-1),translate:L(n,t,s[e]),target:()=>u.get()>a?o:c}}))}return{canLoop:function(){return f.every((({index:n})=>p(a.filter((t=>t!==n)),e)<=.1))},clear:function(){f.forEach((n=>n.translate.clear()))},loop:function(){f.forEach((n=>{const{target:t,translate:e,slideLocation:r}=n,o=t();o!==r.get()&&(e.to(o),r.set(o))}))},loopPoints:f}}function T(n,t){let e,r=!1;return{init:function(o,i){i&&(e=new MutationObserver((n=>{r||(c(i)||i(o,n))&&function(n){for(const e of n)if("childList"===e.type){o.reInit(),t.emit("slidesChanged");break}}(n)})),e.observe(n,{childList:!0}))},destroy:function(){e&&e.disconnect(),r=!0}}}function F(n,t,e,r,o,i,c){const{removeOffset:u,constrain:s}=o,a=i?[0,t,-t]:[0],d=l(a,c);function l(t,o){const i=t||a,c=function(n){const t=n||0;return e.map((n=>x(.5,n-.5).constrain(n*t)))}(o);return i.reduce(((t,o)=>{const i=r.map(((t,r)=>({start:t-e[r]+c[r]+o,end:t+n-c[r]+o,index:r})));return t.concat(i)}),[])}return{check:function(n,t){const e=i?u(n):s(n);return(t||d).reduce(((n,t)=>{const{index:r,start:o,end:i}=t;return!n.includes(r)&&(o<e&&i>e)?n.concat([r]):n}),[])},findSlideBounds:l}}function z(n,t,e){const r=o(e);return{groupSlides:function(o){return r?function(n,t){return l(n).filter((n=>n%t==0)).map((e=>n.slice(e,e+t)))}(o,e):function(e){return l(e).reduce(((e,r)=>{const o=t.slice(f(e),r+1).reduce(((n,t)=>n+t),0);return!r||o>n?e.concat(r):e}),[]).map(((n,t,r)=>e.slice(n,r[t+1])))}(o)}}}function B(n,t,e,r,o,i,c,u){const{align:d,axis:m,direction:g,startIndex:h,inViewThreshold:B,loop:R,duration:j,dragFree:H,dragThreshold:N,slidesToScroll:C,skipSnaps:V,containScroll:q}=i,$=t.getBoundingClientRect(),U=e.map((n=>n.getBoundingClientRect())),W=function(n){const t="rtl"===n?-1:1;return{apply:function(n){return n*t}}}(g),G=function(n,t){const e="y"===n?"y":"x";return{scroll:e,cross:"y"===n?"x":"y",startEdge:"y"===e?"top":"rtl"===t?"right":"left",endEdge:"y"===e?"bottom":"rtl"===t?"left":"right",measureSize:function(n){const{width:t,height:r}=n;return"x"===e?t:r}}}(m,g),J=G.measureSize($),Q=function(n){return{measure:function(t){return n*(t/100)}}}(J),X=y(d,J),Y=!R&&!!q,K=R||!!q,{slideSizes:Z,slideSizesWithGaps:_}=function(n,t,e,r,o,i){const{measureSize:c,startEdge:u,endEdge:a}=n,d=e[0]&&o,l=function(){if(!d)return 0;const n=e[0];return s(t[u]-n[u])}(),m=function(){if(!d)return 0;const n=i.getComputedStyle(f(r));return parseFloat(n.getPropertyValue(`margin-${a}`))}(),g=e.map(c),h=e.map(((n,t,e)=>{const r=!t,o=t===p(e);return r?g[t]+l:o?g[t]+m:e[t+1][u]-n[u]})).map(s);return{slideSizes:g,slideSizesWithGaps:h}}(G,$,U,e,K,o),nn=z(J,_,C),{snaps:tn,snapsAligned:en}=function(n,t,e,r,o,i,c){const{startEdge:u,endEdge:a}=n,{groupSlides:d}=i,l=d(r).map((n=>f(n)[a]-n[0][u])).map(s).map(t.measure),m=r.map((n=>e[u]-n[u])).map((n=>-s(n))),g=function(){const n=f(m)-f(o);return d(m).map((n=>n[0])).map(((t,e,r)=>{const o=!e,i=e===p(r);return c&&o?0:c&&i?n:t+l[e]}))}();return{snaps:m,snapsAligned:g}}(G,X,$,U,_,nn,Y),rn=-f(tn)+f(_),{snapsContained:on}=D(J,rn,en,q),cn=Y?on:en,{limit:un}=function(n,t,e){const r=t[0];return{limit:x(e?r-n:f(t),r)}}(rn,cn,R),sn=b(p(cn),h,R),an=sn.clone(),dn=l(e),ln={start:()=>u.start(vn),stop:()=>u.stop(vn),update:()=>(({dragHandler:n,scrollBody:t,scrollBounds:e,eventHandler:r,animation:o,options:{loop:i}})=>{const c=n.pointerDown();i||e.constrain(c);const u=t.seek().settled();u&&!c&&(o.stop(),r.emit("settle")),u||r.emit("scroll")})(vn),render:n=>(({scrollBody:n,translate:t,location:e,offsetLocation:r,scrollLooper:o,slideLooper:i,options:{loop:c}},u)=>{const s=n.velocity();r.set(e.get()-s+s*u),c&&(o.loop(n.direction()),i.loop()),t.to(r.get())})(vn,n)},fn=cn[sn.get()],pn=I(fn),mn=I(fn),gn=I(fn),hn=function(n,t,e,r){let o=!0,i=0,c=0,u=e,d=r;function l(n){return u=n,p}function f(n){return d=n,p}const p={direction:function(){return c},duration:function(){return u},velocity:function(){return i},seek:function(){const e=t.get()-n.get();return u?(i+=e/u,i*=d,n.add(i)):(i=0,n.set(t)),o=s(e)<.001,p},settled:function(){return o},useBaseFriction:function(){return f(r)},useBaseDuration:function(){return l(e)},useDirection:function(n){return c=a(n),p},useFriction:f,useDuration:l};return p}(pn,gn,j,.68),yn=M(R,cn,rn,un,gn),xn=function(n,t,e,r,o,i,c){function u(r){const u=r.distance,s=r.index!==t.get();o.useDirection(u),i.add(u),u&&(o.duration()?n.start():(n.update(),n.render(1),n.update())),s&&(e.set(t.get()),t.set(r.index),c.emit("select"))}return{distance:function(n,t){u(r.byDistance(n,t))},index:function(n,e){const o=t.clone().set(n);u(r.byIndex(o.get(),e))}}}(ln,sn,an,yn,hn,gn,c),bn=F(J,rn,Z,tn,un,R,B),vn={ownerDocument:r,ownerWindow:o,eventHandler:c,containerRect:$,slideRects:U,animation:ln,axis:G,direction:W,dragHandler:S(G,W,n,r,o,gn,w(G,o),pn,ln,xn,hn,yn,sn,c,Q,H,N,V,.68),eventStore:v(),percentOfView:Q,index:sn,indexPrevious:an,limit:un,location:pn,offsetLocation:mn,options:i,resizeHandler:E(t,c,o,e,G),scrollBody:hn,scrollBounds:O(un,pn,gn,hn,Q),scrollLooper:A(rn,un,mn,[pn,mn,gn]),scrollProgress:k(un),scrollSnaps:cn,scrollTarget:yn,scrollTo:xn,slideLooper:P(G,W,J,rn,_,cn,bn,mn,e),slidesHandler:T(t,c),slidesInView:bn,slideIndexes:dn,slidesToScroll:nn,target:gn,translate:L(G,W,t)};return vn}const R={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,breakpoints:{},dragFree:!1,dragThreshold:10,inViewThreshold:0,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function j(n){function t(n,t){return g(n,t||{})}const e={mergeOptions:t,optionsAtMedia:function(e){const r=e.breakpoints||{},o=m(r).filter((t=>n.matchMedia(t).matches)).map((n=>r[n])).reduce(((n,e)=>t(n,e)),{});return t(e,o)},optionsMediaQueries:function(t){return t.map((n=>m(n.breakpoints||{}))).reduce(((n,t)=>n.concat(t)),[]).map(n.matchMedia)}};return e}function H(n,t,e){const r=n.ownerDocument,o=r.defaultView,c=j(o),u=function(n){let t=[];return{init:function(e,r){return t=e.filter((({options:t})=>!1!==n.optionsAtMedia(t).active)),t.forEach((t=>t.init(r,n))),e.reduce(((n,t)=>Object.assign(n,{[t.name]:t})),{})},destroy:function(){t=t.filter((n=>n.destroy()))}}}(c),a=v(),d=v(),l=function(){const n={};let t;function e(t){return n[t]||[]}const r={init:function(n){t=n},emit:function(n){return e(n).forEach((e=>e(t,n))),r},off:function(t,o){return n[t]=e(t).filter((n=>n!==o)),r},on:function(t,o){return n[t]=e(t).concat([o]),r}};return r}(),{animationRealms:f}=H,{mergeOptions:p,optionsAtMedia:m,optionsMediaQueries:g}=c,{on:h,off:y,emit:x}=l,b=P;let S,w,E,O,D=!1,A=p(R,H.globalOptions),k=p(A),M=[];function I(t,e){const i=B(n,E,O,r,o,t,l,e);if(t.loop&&!i.slideLooper.canLoop()){return I(Object.assign({},t,{loop:!1}),e)}return i}function L(t,e){if(D)return;const c=f.find((n=>n.window===o)),l=c||function(n){const t=1e3/60;let e=[],r=null,o=0,i=0;function c(u){r||(r=u);const a=u-r;for(r=u,o+=a;o>=t;)e.forEach((({animation:n})=>n.update())),o-=t;const d=s(o/t);e.forEach((({animation:n})=>n.render(d))),i&&n.requestAnimationFrame(c)}return{start:function(t){e.includes(t)||e.push(t),i||(i=n.requestAnimationFrame(c))},stop:function(t){e=e.filter((n=>n!==t)),e.length||(n.cancelAnimationFrame(i),r=null,o=0,i=0)},reset:function(){r=null,o=0},window:n}}(o);c||f.push(l),A=p(A,t),k=m(A),M=e||M,function(){const{container:t,slides:e}=k,r=i(t)?n.querySelector(t):t;E=r||n.children[0];const o=i(e)?E.querySelectorAll(e):e;O=[].slice.call(o||E.children)}(),S=I(k,l),g([A,...M.map((({options:n})=>n))]).forEach((n=>a.add(n,"change",P))),k.active&&(S.translate.to(S.location.get()),S.eventHandler.init(C),S.resizeHandler.init(C,k.watchResize),S.slidesHandler.init(C,k.watchSlides),d.add(r,"visibilitychange",(()=>{r.hidden&&l.reset()})),S.options.loop&&S.slideLooper.loop(),E.offsetParent&&O.length&&S.dragHandler.init(C,k.watchDrag),w=u.init(M,C))}function P(n,t){const e=N();T(),L(p({startIndex:e},n),t),l.emit("reInit")}function T(){S.dragHandler.destroy(),S.animation.stop(),S.eventStore.clear(),S.translate.clear(),S.slideLooper.clear(),S.resizeHandler.destroy(),S.slidesHandler.destroy(),u.destroy(),a.clear(),d.clear()}function F(n){const t=S[n?"target":"location"].get(),e=k.loop?"removeOffset":"constrain";return S.slidesInView.check(S.limit[e](t))}function z(n,t,e){k.active&&!D&&(S.scrollBody.useBaseFriction().useDuration(t?0:k.duration),S.scrollTo.index(n,e||0))}function N(){return S.index.get()}const C={canScrollNext:function(){return S.index.add(1).get()!==N()},canScrollPrev:function(){return S.index.add(-1).get()!==N()},containerNode:function(){return E},internalEngine:function(){return S},destroy:function(){D||(D=!0,a.clear(),T(),l.emit("destroy"))},off:y,on:h,emit:x,plugins:function(){return w},previousScrollSnap:function(){return S.indexPrevious.get()},reInit:b,rootNode:function(){return n},scrollNext:function(n){z(S.index.add(1).get(),!0===n,-1)},scrollPrev:function(n){z(S.index.add(-1).get(),!0===n,1)},scrollProgress:function(){return S.scrollProgress.get(S.location.get())},scrollSnapList:function(){return S.scrollSnaps.map(S.scrollProgress.get)},scrollTo:z,selectedScrollSnap:N,slideNodes:function(){return O},slidesInView:F,slidesNotInView:function(n){const t=F(n);return S.slideIndexes.filter((n=>!t.includes(n)))}};return L(t,e),setTimeout((()=>l.emit("init")),0),C}function N(t={},o=[]){const i=n.useRef(t),c=n.useRef(o),[u,s]=n.useState(),[a,d]=n.useState(),l=n.useCallback((()=>{u&&u.reInit(i.current,c.current)}),[u]);return n.useEffect((()=>{if("undefined"!=typeof window&&window.document&&window.document.createElement&&a){H.globalOptions=N.globalOptions;const n=H(a,i.current,c.current);return s(n),()=>n.destroy()}s(void 0)}),[a,s]),n.useEffect((()=>{e(i.current,t)||(i.current=t,l())}),[t,l]),n.useEffect((()=>{(function(n,t){if(n.length!==t.length)return!1;const o=r(n),i=r(t);return o.every(((n,t)=>e(n,i[t])))})(c.current,o)||(c.current=o,l())}),[o,l]),[d,u]}return H.animationRealms=[],H.globalOptions=void 0,N.globalOptions=void 0,N})); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselReact=t(n.React)}(this,(function(n){"use strict";function t(n){return function(n){return"[object Object]"===Object.prototype.toString.call(n)}(n)||Array.isArray(n)}function e(n,r){const o=Object.keys(n),i=Object.keys(r);if(o.length!==i.length)return!1;return JSON.stringify(Object.keys(n.breakpoints||{}))===JSON.stringify(Object.keys(r.breakpoints||{}))&&o.every((o=>{const i=n[o],c=r[o];return"function"==typeof i?`${i}`==`${c}`:t(i)&&t(c)?e(i,c):i===c}))}function r(n){return n.concat().sort(((n,t)=>n.name>t.name?1:-1)).map((n=>n.options))}function o(n){return"number"==typeof n}function i(n){return"string"==typeof n}function c(n){return"boolean"==typeof n}function u(n){return"[object Object]"===Object.prototype.toString.call(n)}function s(n){return Math.abs(n)}function a(n){return Math.sign(n)}function d(n,t){return s(n-t)}function l(n){return m(n).map(Number)}function f(n){return n[p(n)]}function p(n){return Math.max(0,n.length-1)}function m(n){return Object.keys(n)}function g(n,t){return[n,t].reduce(((n,t)=>(m(t).forEach((e=>{const r=n[e],o=t[e],i=u(r)&&u(o);n[e]=i?g(r,o):o})),n)),{})}function h(n,t){return void 0!==t.MouseEvent&&n instanceof t.MouseEvent}function y(n,t){const e={start:function(){return 0},center:function(n){return r(n)/2},end:r};function r(n){return t-n}return{measure:function(r){return o(n)?t*Number(n):e[n](r)}}}function x(n,t){const e=s(n-t);function r(t){return t<n}function o(n){return n>t}function i(n){return r(n)||o(n)}return{length:e,max:t,min:n,constrain:function(e){return i(e)?r(e)?n:t:e},reachedAny:i,reachedMax:o,reachedMin:r,removeOffset:function(n){return e?n-e*Math.ceil((n-t)/e):n}}}function b(n,t,e){const{constrain:r}=x(0,n),o=n+1;let i=c(t);function c(n){return e?s((o+n)%o):r(n)}function u(){return i}function a(){return b(n,u(),e)}const d={get:u,set:function(n){return i=c(n),d},add:function(n){return a().set(u()+n)},clone:a};return d}function v(){let n=[];const t={add:function(e,r,o,i={passive:!0}){return e.addEventListener(r,o,i),n.push((()=>e.removeEventListener(r,o,i))),t},clear:function(){n=n.filter((n=>n()))}};return t}function S(n,t,e,r,o,i,u,l,f,p,m,g,y,b,S,w,E,O,D){const{cross:A}=n,k=["INPUT","SELECT","TEXTAREA"],M={passive:!1},I=v(),L=v(),P=x(50,225).constrain(S.measure(20)),T={mouse:300,touch:400},F={mouse:500,touch:600},z=w?43:25;let B=!1,R=0,j=0,H=!1,N=!1,C=!1,V=!1;function q(n){const e=u.readPoint(n),r=u.readPoint(n,A),o=d(e,R),c=d(r,j);if(!N&&!V){if(!n.cancelable)return $(n);if(N=o>c,!N)return $(n)}const s=u.pointerMove(n);o>E&&(C=!0),m.useFriction(.3).useDuration(1),f.start(),i.add(t.apply(s)),n.preventDefault()}function $(n){const e=g.byDistance(0,!1).index!==y.get(),r=u.pointerUp(n)*(w?F:T)[V?"mouse":"touch"],o=function(n,t){const e=y.add(-1*a(n)),r=g.byDistance(n,!w).distance;return w||s(n)<P?r:O&&t?.5*r:g.byIndex(e.get(),0).distance}(t.apply(r),e),i=function(n,t){if(0===n||0===t)return 0;if(s(n)<=s(t))return 0;const e=d(s(n),s(t));return s(e/n)}(r,o),c=z-10*i,l=D+i/50;N=!1,H=!1,L.clear(),m.useDuration(c).useFriction(l),p.distance(o,!w),V=!1,b.emit("pointerUp")}function U(n){C&&(n.stopPropagation(),n.preventDefault())}return{init:function(n,t){if(!t)return;function s(s){(c(t)||t(n,s))&&function(n){const t=h(n,o);if(V=t,t&&0!==n.button)return;if(function(n){const t=n.nodeName||"";return k.includes(t)}(n.target))return;C=w&&t&&!n.buttons&&B,B=d(i.get(),l.get())>=2,H=!0,u.pointerDown(n),m.useFriction(0).useDuration(0),i.set(l),function(){const n=V?r:e;L.add(n,"touchmove",q,M).add(n,"touchend",$).add(n,"mousemove",q,M).add(n,"mouseup",$)}(),R=u.readPoint(n),j=u.readPoint(n,A),b.emit("pointerDown")}(s)}const a=e;I.add(a,"dragstart",(n=>n.preventDefault()),M).add(a,"touchmove",(()=>{}),M).add(a,"touchend",(()=>{})).add(a,"touchstart",s).add(a,"mousedown",s).add(a,"touchcancel",$).add(a,"contextmenu",$).add(a,"click",U,!0)},pointerDown:function(){return H},destroy:function(){I.clear(),L.clear()}}}function w(n,t){let e,r;function o(n){return n.timeStamp}function i(e,r){const o="client"+("x"===(r||n.scroll)?"X":"Y");return(h(e,t)?e:e.touches[0])[o]}return{pointerDown:function(n){return e=n,r=n,i(n)},pointerMove:function(n){const t=i(n)-i(r),c=o(n)-o(e)>170;return r=n,c&&(e=n),t},pointerUp:function(n){if(!e||!r)return 0;const t=i(r)-i(e),c=o(n)-o(e),u=o(n)-o(r)>170,a=t/c;return c&&!u&&s(a)>.1?a:0},readPoint:i}}function E(n,t,e,r,o){let i,u,s=[],a=!1;function d(n){return o.measureSize(n.getBoundingClientRect())}return{init:function(o,l){if(!l)return;u=d(n),s=r.map(d),i=new ResizeObserver((i=>{a||(c(l)||l(o,i))&&function(i){for(const c of i){const i=c.target===n,a=r.indexOf(c.target);if((i?u:s[a])!==d(i?n:r[a])){e.requestAnimationFrame((()=>{o.reInit(),t.emit("resize")}));break}}}(i)})),[n].concat(r).forEach((n=>i.observe(n)))},destroy:function(){i&&i.disconnect(),a=!0}}}function O(n,t,e,r,o){const i=o.measure(10),c=o.measure(50),u=x(.1,.99);let a=!1;return{constrain:function(o){if(a||!n.reachedAny(e.get())||!n.reachedAny(t.get()))return;const d=n.reachedMin(t.get())?"min":"max",l=s(n[d]-t.get()),f=e.get()-t.get(),p=u.constrain(l/c);e.subtract(f*p),!o&&s(f)<i&&(e.set(n.constrain(e.get())),r.useDuration(25).useBaseFriction())},toggleActive:function(n){a=!n}}}function D(n,t,e,r){const o=x(-t+n,e[0]),i=e.map(o.constrain).map((n=>parseFloat(n.toFixed(3))));return{snapsContained:function(){if(t<=n)return[o.max];if("keepSnaps"===r)return i;const{min:e,max:c}=function(){const n=i[0],t=f(i),e=i.lastIndexOf(n),r=i.indexOf(t)+1;return x(e,r)}();return i.slice(e,c)}()}}function A(n,t,e,r){const o=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:u}=x(o,i);return{loop:function(t){if(!function(n){return 1===n?u(e.get()):-1===n&&c(e.get())}(t))return;const o=n*(-1*t);r.forEach((n=>n.add(o)))}}}function k(n){const{max:t,length:e}=n;return{get:function(n){return(n-t)/-e}}}function M(n,t,e,r,o){const{reachedAny:i,removeOffset:c,constrain:u}=r;function d(n){return n.concat().sort(((n,t)=>s(n)-s(t)))[0]}function l(t,r){const o=[t,t+e,t-e];if(!n)return o[0];if(!r)return d(o);return d(o.filter((n=>a(n)===r)))}return{byDistance:function(e,r){const a=o.get()+e,{index:d,distance:f}=function(e){const r=n?c(e):u(e),o=t.map((n=>n-r)).map((n=>l(n,0))).map(((n,t)=>({diff:n,index:t}))).sort(((n,t)=>s(n.diff)-s(t.diff))),{index:i}=o[0];return{index:i,distance:r}}(a),p=!n&&i(a);return!r||p?{index:d,distance:e}:{index:d,distance:e+l(t[d]-f,0)}},byIndex:function(n,e){return{index:n,distance:l(t[n]-o.get(),e)}},shortcut:l}}function I(n){let t=n;function e(n){return o(n)?n:n.get()}return{get:function(){return t},set:function(n){t=e(n)},add:function(n){t+=e(n)},subtract:function(n){t-=e(n)}}}function L(n,t,e){const r="x"===n.scroll?function(n){return`translate3d(${n}px,0px,0px)`}:function(n){return`translate3d(0px,${n}px,0px)`},o=e.style;let i=!1;return{clear:function(){i||(o.transform="",e.getAttribute("style")||e.removeAttribute("style"))},to:function(n){i||(o.transform=r(t.apply(n)))},toggleActive:function(n){i=!n}}}function P(n,t,e,r,o,i,c,u,s){const a=l(o),d=l(o).reverse(),f=function(){const n=i[0]-1;return g(m(d,n),"end")}().concat(function(){const n=e-i[0]-1;return g(m(a,n),"start")}());function p(n,t){return n.reduce(((n,t)=>n-o[t]),t)}function m(n,t){return n.reduce(((n,e)=>p(n,t)>0?n.concat([e]):n),[])}function g(e,o){const i="start"===o,a=i?-r:r,d=c.findSlideBounds([a]);return e.map((e=>{const o=i?0:-r,c=i?r:0,a=d.filter((n=>n.index===e))[0][i?"end":"start"];return{index:e,slideLocation:I(-1),translate:L(n,t,s[e]),target:()=>u.get()>a?o:c}}))}return{canLoop:function(){return f.every((({index:n})=>p(a.filter((t=>t!==n)),e)<=.1))},clear:function(){f.forEach((n=>n.translate.clear()))},loop:function(){f.forEach((n=>{const{target:t,translate:e,slideLocation:r}=n,o=t();o!==r.get()&&(e.to(o),r.set(o))}))},loopPoints:f}}function T(n,t){let e,r=!1;return{init:function(o,i){i&&(e=new MutationObserver((n=>{r||(c(i)||i(o,n))&&function(n){for(const e of n)if("childList"===e.type){o.reInit(),t.emit("slidesChanged");break}}(n)})),e.observe(n,{childList:!0}))},destroy:function(){e&&e.disconnect(),r=!0}}}function F(n,t,e,r,o,i,c){const{removeOffset:u,constrain:s}=o,a=i?[0,t,-t]:[0],d=l(a,c);function l(t,o){const i=t||a,c=function(n){const t=n||0;return e.map((n=>x(.5,n-.5).constrain(n*t)))}(o);return i.reduce(((t,o)=>{const i=r.map(((t,r)=>({start:t-e[r]+c[r]+o,end:t+n-c[r]+o,index:r})));return t.concat(i)}),[])}return{check:function(n,t){const e=i?u(n):s(n);return(t||d).reduce(((n,t)=>{const{index:r,start:o,end:i}=t;return!n.includes(r)&&(o<e&&i>e)?n.concat([r]):n}),[])},findSlideBounds:l}}function z(n,t,e){const r=o(e);return{groupSlides:function(o){return r?function(n,t){return l(n).filter((n=>n%t==0)).map((e=>n.slice(e,e+t)))}(o,e):function(e){return l(e).reduce(((e,r)=>{const o=t.slice(f(e),r+1).reduce(((n,t)=>n+t),0);return!r||o>n?e.concat(r):e}),[]).map(((n,t,r)=>e.slice(n,r[t+1])))}(o)}}}function B(n,t,e,r,o,i,c,u){const{align:d,axis:m,direction:g,startIndex:h,inViewThreshold:B,loop:R,duration:j,dragFree:H,dragThreshold:N,slidesToScroll:C,skipSnaps:V,containScroll:q}=i,$=t.getBoundingClientRect(),U=e.map((n=>n.getBoundingClientRect())),W=function(n){const t="rtl"===n?-1:1;return{apply:function(n){return n*t}}}(g),G=function(n,t){const e="y"===n?"y":"x";return{scroll:e,cross:"y"===n?"x":"y",startEdge:"y"===e?"top":"rtl"===t?"right":"left",endEdge:"y"===e?"bottom":"rtl"===t?"left":"right",measureSize:function(n){const{width:t,height:r}=n;return"x"===e?t:r}}}(m,g),J=G.measureSize($),Q=function(n){return{measure:function(t){return n*(t/100)}}}(J),X=y(d,J),Y=!R&&!!q,K=R||!!q,{slideSizes:Z,slideSizesWithGaps:_}=function(n,t,e,r,o,i){const{measureSize:c,startEdge:u,endEdge:a}=n,d=e[0]&&o,l=function(){if(!d)return 0;const n=e[0];return s(t[u]-n[u])}(),m=function(){if(!d)return 0;const n=i.getComputedStyle(f(r));return parseFloat(n.getPropertyValue(`margin-${a}`))}(),g=e.map(c),h=e.map(((n,t,e)=>{const r=!t,o=t===p(e);return r?g[t]+l:o?g[t]+m:e[t+1][u]-n[u]})).map(s);return{slideSizes:g,slideSizesWithGaps:h}}(G,$,U,e,K,o),nn=z(J,_,C),{snaps:tn,snapsAligned:en}=function(n,t,e,r,o,i,c){const{startEdge:u,endEdge:a}=n,{groupSlides:d}=i,l=d(r).map((n=>f(n)[a]-n[0][u])).map(s).map(t.measure),m=r.map((n=>e[u]-n[u])).map((n=>-s(n))),g=function(){const n=f(m)-f(o);return d(m).map((n=>n[0])).map(((t,e,r)=>{const o=!e,i=e===p(r);return c&&o?0:c&&i?n:t+l[e]}))}();return{snaps:m,snapsAligned:g}}(G,X,$,U,_,nn,Y),rn=-f(tn)+f(_),{snapsContained:on}=D(J,rn,en,q),cn=Y?on:en,{limit:un}=function(n,t,e){const r=t[0];return{limit:x(e?r-n:f(t),r)}}(rn,cn,R),sn=b(p(cn),h,R),an=sn.clone(),dn=l(e),ln={start:()=>u.start(vn),stop:()=>u.stop(vn),update:()=>(({dragHandler:n,scrollBody:t,scrollBounds:e,eventHandler:r,animation:o,options:{loop:i}})=>{const c=n.pointerDown();i||e.constrain(c);const u=t.seek().settled();u&&!c&&(o.stop(),r.emit("settle")),u||r.emit("scroll")})(vn),render:n=>(({scrollBody:n,translate:t,location:e,offsetLocation:r,scrollLooper:o,slideLooper:i,options:{loop:c}},u)=>{const s=n.velocity();r.set(e.get()-s+s*u),c&&(o.loop(n.direction()),i.loop()),t.to(r.get())})(vn,n)},fn=cn[sn.get()],pn=I(fn),mn=I(fn),gn=I(fn),hn=function(n,t,e,r){let o=!0,i=0,c=0,u=e,d=r,l=n.get(),f=0;function p(n){return u=n,g}function m(n){return d=n,g}const g={direction:function(){return c},duration:function(){return u},velocity:function(){return i},seek:function(){const e=t.get()-n.get();let r=0;return u?(i+=e/u,i*=d,l+=i,n.add(i),r=l-f):(i=0,n.set(t),r=e),c=a(r),f=l,o=s(e)<.001,g},settled:function(){return o},useBaseFriction:function(){return m(r)},useBaseDuration:function(){return p(e)},useFriction:m,useDuration:p};return g}(pn,gn,j,.68),yn=M(R,cn,rn,un,gn),xn=function(n,t,e,r,o,i,c){function u(r){const u=r.distance,s=r.index!==t.get();i.add(u),u&&(o.duration()?n.start():(n.update(),n.render(1),n.update())),s&&(e.set(t.get()),t.set(r.index),c.emit("select"))}return{distance:function(n,t){u(r.byDistance(n,t))},index:function(n,e){const o=t.clone().set(n);u(r.byIndex(o.get(),e))}}}(ln,sn,an,yn,hn,gn,c),bn=F(J,rn,Z,tn,un,R,B),vn={ownerDocument:r,ownerWindow:o,eventHandler:c,containerRect:$,slideRects:U,animation:ln,axis:G,direction:W,dragHandler:S(G,W,n,r,o,gn,w(G,o),pn,ln,xn,hn,yn,sn,c,Q,H,N,V,.68),eventStore:v(),percentOfView:Q,index:sn,indexPrevious:an,limit:un,location:pn,offsetLocation:mn,options:i,resizeHandler:E(t,c,o,e,G),scrollBody:hn,scrollBounds:O(un,pn,gn,hn,Q),scrollLooper:A(rn,un,mn,[pn,mn,gn]),scrollProgress:k(un),scrollSnaps:cn,scrollTarget:yn,scrollTo:xn,slideLooper:P(G,W,J,rn,_,cn,bn,mn,e),slidesHandler:T(t,c),slidesInView:bn,slideIndexes:dn,slidesToScroll:nn,target:gn,translate:L(G,W,t)};return vn}const R={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,breakpoints:{},dragFree:!1,dragThreshold:10,inViewThreshold:0,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function j(n){function t(n,t){return g(n,t||{})}const e={mergeOptions:t,optionsAtMedia:function(e){const r=e.breakpoints||{},o=m(r).filter((t=>n.matchMedia(t).matches)).map((n=>r[n])).reduce(((n,e)=>t(n,e)),{});return t(e,o)},optionsMediaQueries:function(t){return t.map((n=>m(n.breakpoints||{}))).reduce(((n,t)=>n.concat(t)),[]).map(n.matchMedia)}};return e}function H(n,t,e){const r=n.ownerDocument,o=r.defaultView,c=j(o),u=function(n){let t=[];return{init:function(e,r){return t=e.filter((({options:t})=>!1!==n.optionsAtMedia(t).active)),t.forEach((t=>t.init(r,n))),e.reduce(((n,t)=>Object.assign(n,{[t.name]:t})),{})},destroy:function(){t=t.filter((n=>n.destroy()))}}}(c),a=v(),d=v(),l=function(){const n={};let t;function e(t){return n[t]||[]}const r={init:function(n){t=n},emit:function(n){return e(n).forEach((e=>e(t,n))),r},off:function(t,o){return n[t]=e(t).filter((n=>n!==o)),r},on:function(t,o){return n[t]=e(t).concat([o]),r}};return r}(),{animationRealms:f}=H,{mergeOptions:p,optionsAtMedia:m,optionsMediaQueries:g}=c,{on:h,off:y,emit:x}=l,b=P;let S,w,E,O,D=!1,A=p(R,H.globalOptions),k=p(A),M=[];function I(t,e){const i=B(n,E,O,r,o,t,l,e);if(t.loop&&!i.slideLooper.canLoop()){return I(Object.assign({},t,{loop:!1}),e)}return i}function L(t,e){if(D)return;const c=f.find((n=>n.window===o)),l=c||function(n){const t=1e3/60;let e=[],r=null,o=0,i=0;function c(u){r||(r=u);const a=u-r;for(r=u,o+=a;o>=t;)e.forEach((({animation:n})=>n.update())),o-=t;const d=s(o/t);e.forEach((({animation:n})=>n.render(d))),i&&n.requestAnimationFrame(c)}return{start:function(t){e.includes(t)||e.push(t),i||(i=n.requestAnimationFrame(c))},stop:function(t){e=e.filter((n=>n!==t)),e.length||(n.cancelAnimationFrame(i),r=null,o=0,i=0)},reset:function(){r=null,o=0},window:n}}(o);c||f.push(l),A=p(A,t),k=m(A),M=e||M,function(){const{container:t,slides:e}=k,r=i(t)?n.querySelector(t):t;E=r||n.children[0];const o=i(e)?E.querySelectorAll(e):e;O=[].slice.call(o||E.children)}(),S=I(k,l),g([A,...M.map((({options:n})=>n))]).forEach((n=>a.add(n,"change",P))),k.active&&(S.translate.to(S.location.get()),S.eventHandler.init(C),S.resizeHandler.init(C,k.watchResize),S.slidesHandler.init(C,k.watchSlides),d.add(r,"visibilitychange",(()=>{r.hidden&&l.reset()})),S.options.loop&&S.slideLooper.loop(),E.offsetParent&&O.length&&S.dragHandler.init(C,k.watchDrag),w=u.init(M,C))}function P(n,t){const e=N();T(),L(p({startIndex:e},n),t),l.emit("reInit")}function T(){S.dragHandler.destroy(),S.animation.stop(),S.eventStore.clear(),S.translate.clear(),S.slideLooper.clear(),S.resizeHandler.destroy(),S.slidesHandler.destroy(),u.destroy(),a.clear(),d.clear()}function F(n){const t=S[n?"target":"location"].get(),e=k.loop?"removeOffset":"constrain";return S.slidesInView.check(S.limit[e](t))}function z(n,t,e){k.active&&!D&&(S.scrollBody.useBaseFriction().useDuration(t?0:k.duration),S.scrollTo.index(n,e||0))}function N(){return S.index.get()}const C={canScrollNext:function(){return S.index.add(1).get()!==N()},canScrollPrev:function(){return S.index.add(-1).get()!==N()},containerNode:function(){return E},internalEngine:function(){return S},destroy:function(){D||(D=!0,a.clear(),T(),l.emit("destroy"))},off:y,on:h,emit:x,plugins:function(){return w},previousScrollSnap:function(){return S.indexPrevious.get()},reInit:b,rootNode:function(){return n},scrollNext:function(n){z(S.index.add(1).get(),!0===n,-1)},scrollPrev:function(n){z(S.index.add(-1).get(),!0===n,1)},scrollProgress:function(){return S.scrollProgress.get(S.location.get())},scrollSnapList:function(){return S.scrollSnaps.map(S.scrollProgress.get)},scrollTo:z,selectedScrollSnap:N,slideNodes:function(){return O},slidesInView:F,slidesNotInView:function(n){const t=F(n);return S.slideIndexes.filter((n=>!t.includes(n)))}};return L(t,e),setTimeout((()=>l.emit("init")),0),C}function N(t={},o=[]){const i=n.useRef(t),c=n.useRef(o),[u,s]=n.useState(),[a,d]=n.useState(),l=n.useCallback((()=>{u&&u.reInit(i.current,c.current)}),[u]);return n.useEffect((()=>{if("undefined"!=typeof window&&window.document&&window.document.createElement&&a){H.globalOptions=N.globalOptions;const n=H(a,i.current,c.current);return s(n),()=>n.destroy()}s(void 0)}),[a,s]),n.useEffect((()=>{e(i.current,t)||(i.current=t,l())}),[t,l]),n.useEffect((()=>{(function(n,t){if(n.length!==t.length)return!1;const o=r(n),i=r(t);return o.every(((n,t)=>e(n,i[t])))})(c.current,o)||(c.current=o,l())}),[o,l]),[d,u]}return H.animationRealms=[],H.globalOptions=void 0,N.globalOptions=void 0,N})); |
{ | ||
"name": "embla-carousel-react", | ||
"version": "8.0.0-rc10", | ||
"version": "8.0.0-rc11", | ||
"author": "David Jerleke", | ||
@@ -59,4 +59,4 @@ "description": "A lightweight carousel library with fluid motion and great swipe precision", | ||
"dependencies": { | ||
"embla-carousel": "8.0.0-rc10", | ||
"embla-carousel-reactive-utils": "8.0.0-rc10" | ||
"embla-carousel": "8.0.0-rc11", | ||
"embla-carousel-reactive-utils": "8.0.0-rc11" | ||
}, | ||
@@ -63,0 +63,0 @@ "peerDependencies": { |
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
26175
+ Addedembla-carousel@8.0.0-rc11(transitive)
+ Addedembla-carousel-reactive-utils@8.0.0-rc11(transitive)
- Removedembla-carousel@8.0.0-rc10(transitive)
- Removedembla-carousel-reactive-utils@8.0.0-rc10(transitive)
Updatedembla-carousel@8.0.0-rc11