embla-carousel
Advanced tools
Comparing version 3.0.7 to 3.0.8
@@ -1,2 +0,1756 @@ | ||
!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(e-n)/2},end:function(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,u=o?"loop":"constrain",c=f(e);function s(){return c}function l(n){return c=f(n),d}function f(n){return r[u](n)}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.filter((function(n){return n()})),n.length=0,e}};return e}function a(n){var e=n.target,t=n.scrollBody,a=n.dragFree,u=n.animation,c=n.axis,s=n.element,l=n.dragTracker,f=n.location,d=n.events,m=n.limit,v=c.scroll,p=c.cross,g=["INPUT","SELECT","TEXTAREA"],x=r(0),h=r(0),S=r(0),y=i(),w=i(),b=y.removeAll,T=w.removeAll,M={mouse:2.5,touch:3.5},z={mouse:4,touch:7},D={mouse:12,touch:14},E={mouse:6,touch:5},P=!1,A=!1,I=!1,B=!1;function L(n){if(!(B="mousedown"===n.type)||0===n.button){var r,o,i=k(e.get(),f.get())>=2,a=B||!i,u=(r=n.target,o=r.nodeName||"",!(g.indexOf(o)>-1)),c=i||B&&u;P=!0,l.pointerDown(n),S.set(e),e.set(f),t.useDefaultMass().useSpeed(80),function(){var n=B?document:s;w.add(n,"touchmove",C).add(n,"touchend",O).add(n,"mousemove",C).add(n,"mouseup",O)}(),x.set(l.readPoint(n,v)),h.set(l.readPoint(n,p)),d.emit("pointerDown"),a&&(I=!1),c&&n.preventDefault()}}function C(t){if(!A&&!B){var r=l.readPoint(t,v).get(),o=l.readPoint(t,p).get(),i=k(r,x.get()),a=k(o,h.get());if(!(A=i>a)&&!I)return O()}var c=l.pointerMove(t),s=m.reachedAny(f.get()),d=!n.loop&&s?2:1;!I&&c&&(I=!0),u.start(),e.add(c/d),t.preventDefault()}function O(){var r=l.pointerUp()*(a?z:M)[B?"mouse":"touch"];k(e.get(),S.get())>=.5&&!B&&(I=!0),B=!1,A=!1,P=!1,w.removeAll(),t.useSpeed((a?E:D)[B?"mouse":"touch"]),function(t){var r=n.scrollTo,i=n.scrollTarget,u=n.index,c=m.reachedAny(e.get()+t),s=!(i.byDistance(0,!1).index!==u.get())&&Math.abs(t)>4;if(a||c||!s)r.distance(t,!a);else{var l=-1*o(t).get(),f=u.clone().add(l);r.index(f.get(),0)}}(r),d.emit("pointerUp")}function k(n,e){return Math.abs(n-e)}function N(n){I&&n.preventDefault()}return{addActivationEvents:function(){var n=s;y.add(n,"touchmove",(function(){})).add(n,"touchend",(function(){})).add(n,"touchstart",L).add(n,"mousedown",L).add(n,"touchcancel",O).add(n,"contextmenu",O).add(n,"click",N)},clickAllowed:function(){return!I},pointerDown:function(){return P},removeActivationEvents:b,removeInteractionEvents:T}}function u(n){var e=n.axis,t=n.pxToPercent,o=e.scroll,i={x:"clientX",y:"clientY"},a=r(0),u=r(0),c=r(0),s=r(0),l=[],f=(new Date).getTime(),d=!1;function m(n,e){d=!n.touches;var t=i[e],r=d?n[t]:n.touches[0][t];return s.set(r)}return{pointerDown:function(n){var e=m(n,o);return a.set(e),c.set(e),t.measure(a.get())},pointerMove:function(n){var e=m(n,o),r=(new Date).getTime();return r-f>=10&&(l.push(e.get()),f=r),u.set(e).subtract(c),c.set(e),t.measure(u.get())},pointerUp:function(){var n=c.get(),e=d?5:4,r=l.slice(-e).map((function(e){return n-e})).sort((function(n,e){return Math.abs(n)<Math.abs(e)?1:-1}))[0];return c.set(r||0),l=[],t.measure(c.get())},readPoint:m}}function c(n){var e=n.min,t=n.max,r={min:t,max:e},o={min:e,max:t},i=Math.abs(e-t);function a(n){return n<e}function u(n){return n>t}function c(n){return a(n)?"min":u(n)?"max":""}return{constrain:function(n){var e=c(n);return e?o[e]:n},length:i,loop:function(n){var e=c(n);return e?r[e]:n},max:t,min:e,reachedAny:function(n){return a(n)||u(n)},reachedMax:u,reachedMin:a,removeOffset:function(n){if(e===t)return n;for(;a(n);)n+=i;for(;u(n);)n-=i;return n}}}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 f(n,e){var t=n.classList;t.contains(e)&&t.remove(e)}function d(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),u=r(0),c=r(0),l=r(0),f=o(0),d={speed:t,mass:i};function m(n){return d.speed=n,p}function v(n){return d.mass=n,p}var p={direction:f,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=d.speed,i+(t-r)/(o-r)*(a-i));return f.set(l),l.normalize().multiply(m).subtract(u),function(n){n.divide(d.mass),c.add(n)}(l),p},settle:function(n){var t=n.get()-e.get(),r=!a(t);return r&&e.set(n),r},update:function(){u.add(c),e.add(u),c.multiply(0)},useDefaultMass:function(){return v(i),p},useDefaultSpeed:function(){return m(t),p},useMass:v,useSpeed:m};return p}function v(n){var e=n.limit,t=n.location,r=n.scrollBody,o=n.animation,i=e.min,a=e.max,u=e.reachedMin,c=e.reachedMax,s=!1,l=0;return{constrain:function(n){(function(n){return!s&&!l&&(u(t.get())?n.get()!==i:!!c(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 p(n){var e=n.alignment,t=n.contentSize,r=n.viewSize,o=c({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 c({min:n.lastIndexOf(e)+1,max:n.indexOf(t)})}(t),u=r.min,s=r.max;return a?e?t.slice(u-1,s+1):t:i}}}function g(n){var e=n.contentSize,t=n.location,r=n.limit,o=n.pxToPercent,i=c({min:r.min+o.measure(.1),max:r.max+o.measure(.1)}),a=i.reachedMin,u=i.reachedMax;return{loop:function(n,r){if(function(n){return 1===n?u(t.get()):-1===n&&a(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,u=t.removeOffset;function c(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 c(c(r,i),a);var u=c(r,1===t?i:a);return Math.abs(u)*t}return{byDistance:function(t,o){var c=n.target.get()+t,l=function(n){var e=u(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}}(c),f=function(t,r){if(!(!e&&a(t)))return r;var o=n.index,u=o.min,c=o.max;return i(t)?u:c}(c,l.index),d=!e&&a(c);return!o||d?{index:f,distance:t}:{index:f,distance:t+s(r[f]-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,r,o=n.axis,i=n.location,a=n.contentSize,u=n.viewSize,c=n.slideSizes,s=n.scrollSnaps,f=l(c),d=l(c).reverse(),m=(e=s[0]-1,t=g(e,d),r=x(e,t,0),h(t,r,1)).concat(function(){var n=g(u-s[0]-1,f),e=x(a,f,-u);return h(n,-e,0)}()),v="x"===o.scroll?"left":"top";function p(n,e){return n.reduce((function(n,e){return n-c[e]}),e)}function g(n,e){return e.reduce((function(e,t){return p(e,n)>0?e.concat([t]):e}),[])}function x(n,e,t){return e.reduce((function(e,t){var r=e+c[t];return r<n?r:e}),t)}function h(n,e,t){var r=n.slice().sort((function(n,e){return n-e}));return r.map((function(n,o){var i=a*(t?-1:0),u=a*(t?0:1),c=function(n,e,t){var r=f.length-1;return p(n.map((function(n){return(n+t)%r})),e)}(r.slice(0,o),e,t);return{point:c,getTarget:function(n){return n>c?i:u},index:n,location:-1}}))}return{canLoop:function(){return m.every((function(n){var e=n.index;return p(f.filter((function(n){return n!==e})),u)<=0}))},clear:function(n){m.forEach((function(e){var t=e.index;n[t].style[v]=""}))},loop:function(n){m.forEach((function(e){var t=e.getTarget,r=e.location,o=e.index,a=t(i.get());a!==r&&(n[o].style[v]=a+"%",e.location=a)}))},loopPoints:m}}function S(n){var e=n.contentSize,t=n.slideSizes,r=n.viewSize,o=n.inViewThreshold,i=n.loop,a=t.map((function(n){return n*o})),u=l(t).map((function(n){return t.slice(0,n).reduce((function(n,e){return n-e}),0)})),c=(i?[0,e,-e]:[0]).map(s).reduce((function(n,e){return n.concat(e)}),[]);function s(n){return u.map((function(e,o){return{start:e-t[o]+a[o]+n,end:e+r-a[o]+n,index:o}}))}return{check:function(n){return c.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}),[])}}}function y(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,u=0;return{clear:function(){i.transform="",u=0},to:function(n){if(!a){var e=o(n.get());u!==e&&(getComputedStyle(t).transform,i.transform=r(e),u=e)}},toggleActive:function(n){a=!n}}}function w(n,o,i,s,f){var d,w,b,T,M=s.align,z=s.axis,D=s.startIndex,E=s.inViewThreshold,P=s.loop,A=s.speed,I=s.dragFree,B=s.slidesToScroll,L=s.containScroll,C=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}}(z),O=function(n){var e={measure:function(e){return e/n*100},totalPercent:100};return Object.freeze(e)}(C.measure(o)),k=O.totalPercent,N=i.map(C.measure).map(O.measure),U=function(n,e){for(var t=[],r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}(N,B).map((function(n){return n.reduce((function(n,e){return n+e}))})),V=l(U),F=N.reduce((function(n,e){return n+e}),0),j=e({align:M,viewSize:k}),H=function(n){var e,r=n.snapSizes,o=n.alignment,i=n.loop,a=r.map(o.measure),u=(e=t({limit:c({min:0,max:r.length-1}),start:0,loop:i}),r.map((function(n,t){var r=e.set(t+1).get();return n+a[t]-a[r]})));return{measure:function(n){return u.slice(0,n).reduce((function(n,e){return n-e}),a[0])}}}({snapSizes:U,alignment:j,loop:P}),q=V.map(H.measure),R=p({alignment:j,contentSize:F,viewSize:k}),X=!P&&""!==L,G="trimSnaps"===L,Y=R.measure(q,G),J=X?Y:q,K=t({limit:c({min:0,max:J.length-1}),start:D,loop:P}),Q=K.clone(),W=function(n){var e=n.contentSize,t=n.loop;return{measure:function(n){var r=n[0],o=n[n.length-1];return c({min:t?r-e:o,max:r})}}}({loop:P,contentSize:F}).measure(J),Z=function(n){var e=requestAnimationFrame.bind(window),t=cancelAnimationFrame.bind(window),r=0;function o(n,e){return function(){n===!!r&&e()}}function i(){r=e(n)}return{proceed:o(!0,i),start:o(!1,i),stop:o(!0,(function(){t(r),r=0}))}}((function(){un.scrollBody.seek(nn).update();var n=un.scrollBody.settle(nn);if(an.pointerDown()||(P||un.scrollBounds.constrain(nn),n&&(un.animation.stop(),f.emit("settle"))),P){var e=un.scrollBody.direction.get();un.scrollLooper.loop(en,e),un.slideLooper.loop(i)}n||f.emit("scroll"),un.translate.to(un.scrollBody.location),un.animation.proceed()})),$=J[K.get()],_=r($),nn=r($),en=[_,nn],tn=m({location:_,speed:A,mass:1}),rn=x({contentSize:F,index:K,limit:W,loop:P,scrollSnaps:J,target:nn}),on=function(n){var e=n.index,t=n.scrollTarget,r=n.animation,o=n.indexPrevious,i=n.events,a=n.target;function u(n){var t=n.distance,u=n.index!==e.get();t&&(r.start(),a.add(t)),u&&(o.set(e.get()),e.set(n.index),i.emit("select"))}return{distance:function(n,e){u(t.byDistance(n,e))},index:function(n,r){var o=e.clone().set(n);u(t.byIndex(o.get(),r))}}}({animation:Z,events:f,index:K,indexPrevious:Q,scrollTarget:rn,target:nn}),an=a({animation:Z,axis:C,dragFree:I,dragTracker:u({axis:C,pxToPercent:O}),element:n,events:f,index:K,limit:W,location:_,loop:P,scrollBody:tn,scrollTo:on,scrollTarget:rn,target:nn}),un={animation:Z,axis:C,dragHandler:an,pxToPercent:O,index:K,indexPrevious:Q,limit:W,location:_,options:s,scrollBody:tn,scrollBounds:v({animation:Z,limit:W,location:_,scrollBody:tn}),scrollLooper:g({contentSize:F,limit:W,location:_,pxToPercent:O}),scrollProgress:(d={limit:W},w=d.limit,b=w.max,T=w.length,{get:function(n){return(n-b)/-T}}),scrollSnaps:J,scrollTarget:rn,scrollTo:on,slideLooper:h({axis:C,contentSize:F,location:_,scrollSnaps:J,slideSizes:N,viewSize:k}),slidesInView:S({contentSize:F,inViewThreshold:E,loop:P,slideSizes:N,viewSize:k}),snapIndexes:V,target:nn,translate:y({axis:C,container:o})};return un}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){void 0===t&&(t={});var r,o,a,u,c,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(),v=(r=function(){var n=u.axis.measure(c);y!==n&&P(),l.emit("resize")},o=500,a={id:0},function(){window.clearTimeout(a.id),a.id=window.setTimeout(r,o)||0}),p=P,g=l.on,x=l.off,h=!1,S=n({},b),y=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=(c=r).children,s=Array.prototype.slice.call(n)}function M(t){void 0===t&&(t={}),T(),S=n(S,t);var r=(u=w(e,c,s,S,l)).axis,o=u.scrollBody,i=u.translate,a=u.dragHandler,f=u.slideLooper,p=S.loop,g=S.draggable,x=S.draggableClass,b=S.selectedClass,M=S.draggingClass;if(y=r.measure(c),m.add(window,"resize",v),i.to(o.location),s.forEach(E),a.addActivationEvents(),p){if(!f.canLoop())return P({loop:!1});f.loop(s)}g?(x&&d(e,x),M&&(l.on("pointerDown",z),l.on("pointerUp",z))):l.on("pointerDown",a.removeInteractionEvents),b&&(D(),l.on("select",D),l.on("pointerUp",D)),h||(setTimeout((function(){return l.emit("init")}),0),h=!0)}function z(n){var t=S.draggingClass;"pointerDown"===n?d(e,t):f(e,t)}function D(){var n=S.selectedClass,e=I(!0);B(!0).forEach((function(e){return f(s[e],n)})),e.forEach((function(e){return d(s[e],n)}))}function E(n,t){m.add(n,"focus",(function(){var n=Math.floor(t/S.slidesToScroll),r=t?n:t;e.scrollLeft=0,L(r)}),!0)}function P(e){void 0===e&&(e={});var t=n({startIndex:u.index.get()},e);A(),M(t),l.emit("reInit")}function A(){var n=S.selectedClass,t=S.draggableClass;u.dragHandler.removeActivationEvents(),u.dragHandler.removeInteractionEvents(),u.animation.stop(),m.removeAll(),u.translate.clear(),u.slideLooper.clear(s),f(e,t),s.forEach((function(e){return f(e,n)})),l.off("select",D),l.off("pointerUp",D),l.off("pointerDown",z),l.off("pointerUp",z)}function I(n){void 0===n&&(n=!1);var e=u[n?"target":"location"].get(),t=S.loop?"removeOffset":"constrain";return u.slidesInView.check(u.limit[t](e))}function B(n){void 0===n&&(n=!1);var e=I(n);return u.snapIndexes.filter((function(n){return-1===e.indexOf(n)}))}function L(n){u.scrollBody.useDefaultMass().useDefaultSpeed(),u.scrollTo.index(n,0)}return M(t),{canScrollNext:function(){var n=u.index;return S.loop||n.get()!==n.max},canScrollPrev:function(){var n=u.index;return S.loop||n.get()!==n.min},clickAllowed:function(){return u.dragHandler.clickAllowed()},containerNode:function(){return c},dangerouslyGetEngine:function(){return u},destroy:function(){h&&(A(),h=!1,u={},l.emit("destroy"))},off:x,on:g,previousScrollSnap:function(){return u.indexPrevious.get()},reInit:p,scrollNext:function(){var n=u.index.clone().add(1);u.scrollBody.useDefaultMass().useDefaultSpeed(),u.scrollTo.index(n.get(),-1)},scrollPrev:function(){var n=u.index.clone().add(-1);u.scrollBody.useDefaultMass().useDefaultSpeed(),u.scrollTo.index(n.get(),1)},scrollProgress:function(){var n=u.location.get();return u.scrollProgress.get(n)},scrollSnapList:function(){var n=u.scrollProgress.get;return u.scrollSnaps.map(n)},scrollTo:L,selectedScrollSnap:function(){return u.index.get()},slideNodes:function(){return s},slidesInView:I,slidesNotInView:B}}})); | ||
'use strict'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function Alignment(params) { | ||
var viewSize = params.viewSize, | ||
align = params.align; | ||
var predefined = { | ||
start: start, | ||
center: center, | ||
end: end | ||
}; | ||
function start() { | ||
return 0; | ||
} | ||
function center(n) { | ||
return (viewSize - n) / 2; | ||
} | ||
function end(n) { | ||
return viewSize - n; | ||
} | ||
function percent() { | ||
return viewSize * Number(align); | ||
} | ||
function measure(n) { | ||
if (typeof align === 'number') return percent(); | ||
return predefined[align](n); | ||
} | ||
var self = { | ||
measure: measure | ||
}; | ||
return self; | ||
} | ||
function Animation(callback) { | ||
var run = requestAnimationFrame.bind(window); | ||
var end = cancelAnimationFrame.bind(window); | ||
var animationFrame = 0; | ||
function ifAnimating(active, cb) { | ||
return function () { | ||
if (active === !!animationFrame) cb(); | ||
}; | ||
} | ||
function start() { | ||
animationFrame = run(callback); | ||
} | ||
function stop() { | ||
end(animationFrame); | ||
animationFrame = 0; | ||
} | ||
var self = { | ||
proceed: ifAnimating(true, start), | ||
start: ifAnimating(false, start), | ||
stop: ifAnimating(true, stop) | ||
}; | ||
return self; | ||
} | ||
function Axis(axis) { | ||
var scroll = axis === 'y' ? 'y' : 'x'; | ||
var cross = axis === 'y' ? 'x' : 'y'; | ||
function measure(node) { | ||
var _a = node.getBoundingClientRect(), | ||
width = _a.width, | ||
height = _a.height; | ||
return scroll === 'x' ? width : height; | ||
} | ||
var self = { | ||
cross: cross, | ||
measure: measure, | ||
scroll: scroll | ||
}; | ||
return self; | ||
} | ||
function Counter(params) { | ||
var start = params.start, | ||
limit = params.limit, | ||
loop = params.loop; | ||
var min = limit.min, | ||
max = limit.max; | ||
var type = loop ? 'loop' : 'constrain'; | ||
var counter = withinLimit(start); | ||
function get() { | ||
return counter; | ||
} | ||
function set(n) { | ||
counter = withinLimit(n); | ||
return self; | ||
} | ||
function withinLimit(n) { | ||
return limit[type](n); | ||
} | ||
function add(n) { | ||
if (n !== 0) { | ||
var sign = n / Math.abs(n); | ||
set(get() + sign); | ||
return add(n + sign * -1); | ||
} | ||
return self; | ||
} | ||
function clone() { | ||
return Counter({ | ||
start: get(), | ||
limit: limit, | ||
loop: loop | ||
}); | ||
} | ||
var self = { | ||
add: add, | ||
clone: clone, | ||
get: get, | ||
max: max, | ||
min: min, | ||
set: set | ||
}; | ||
return self; | ||
} | ||
function Vector1D(value) { | ||
var vector = value; | ||
function get() { | ||
return vector; | ||
} | ||
function set(n) { | ||
vector = readNumber(n); | ||
return self; | ||
} | ||
function add(n) { | ||
vector += readNumber(n); | ||
return self; | ||
} | ||
function subtract(n) { | ||
vector -= readNumber(n); | ||
return self; | ||
} | ||
function multiply(n) { | ||
vector *= n; | ||
return self; | ||
} | ||
function divide(n) { | ||
vector /= n; | ||
return self; | ||
} | ||
function normalize() { | ||
if (vector !== 0) divide(vector); | ||
return self; | ||
} | ||
function readNumber(n) { | ||
return typeof n === 'number' ? n : n.get(); | ||
} | ||
var self = { | ||
add: add, | ||
divide: divide, | ||
get: get, | ||
multiply: multiply, | ||
normalize: normalize, | ||
set: set, | ||
subtract: subtract | ||
}; | ||
return self; | ||
} | ||
function Direction(value) { | ||
var direction = Vector1D(normalize(value)); | ||
var get = direction.get; | ||
function normalize(n) { | ||
return n === 0 ? 0 : n / Math.abs(n); | ||
} | ||
function set(v) { | ||
var d = normalize(v.get()); | ||
if (d !== 0) direction.set(d); | ||
return self; | ||
} | ||
var self = { | ||
get: get, | ||
set: set | ||
}; | ||
return self; | ||
} | ||
function EventStore() { | ||
var listeners = []; | ||
function add(node, type, handler, options) { | ||
if (options === void 0) { | ||
options = false; | ||
} | ||
node.addEventListener(type, handler, options); | ||
listeners.push(function () { | ||
return node.removeEventListener(type, handler, options); | ||
}); | ||
return self; | ||
} | ||
function removeAll() { | ||
listeners.filter(function (remove) { | ||
return remove(); | ||
}); | ||
listeners.length = 0; | ||
return self; | ||
} | ||
var self = { | ||
add: add, | ||
removeAll: removeAll | ||
}; | ||
return self; | ||
} | ||
function DragHandler(params) { | ||
var target = params.target, | ||
scrollBody = params.scrollBody, | ||
dragFree = params.dragFree, | ||
animation = params.animation, | ||
axis = params.axis; | ||
var element = params.element, | ||
dragTracker = params.dragTracker, | ||
location = params.location, | ||
events = params.events, | ||
limit = params.limit; | ||
var scrollAxis = axis.scroll, | ||
crossAxis = axis.cross; | ||
var focusNodes = ['INPUT', 'SELECT', 'TEXTAREA']; | ||
var startScroll = Vector1D(0); | ||
var startCross = Vector1D(0); | ||
var dragStartPoint = Vector1D(0); | ||
var activationEvents = EventStore(); | ||
var interactionEvents = EventStore(); | ||
var removeActivationEvents = activationEvents.removeAll; | ||
var removeInteractionEvents = interactionEvents.removeAll; | ||
var snapForceBoost = { | ||
mouse: 2.5, | ||
touch: 3.5 | ||
}; | ||
var freeForceBoost = { | ||
mouse: 4, | ||
touch: 7 | ||
}; | ||
var snapSpeed = { | ||
mouse: 12, | ||
touch: 14 | ||
}; | ||
var freeSpeed = { | ||
mouse: 6, | ||
touch: 5 | ||
}; | ||
var dragThreshold = 4; | ||
var pointerIsDown = false; | ||
var preventScroll = false; | ||
var preventClick = false; | ||
var isMouse = false; | ||
function addActivationEvents() { | ||
var node = element; | ||
activationEvents.add(node, 'touchmove', function () { | ||
return undefined; | ||
}).add(node, 'touchend', function () { | ||
return undefined; | ||
}).add(node, 'touchstart', down).add(node, 'mousedown', down).add(node, 'touchcancel', up).add(node, 'contextmenu', up).add(node, 'click', click); | ||
} | ||
function addInteractionEvents() { | ||
var node = !isMouse ? element : document; | ||
interactionEvents.add(node, 'touchmove', move).add(node, 'touchend', up).add(node, 'mousemove', move).add(node, 'mouseup', up); | ||
} | ||
function isFocusNode(node) { | ||
var name = node.nodeName || ''; | ||
return focusNodes.indexOf(name) > -1; | ||
} | ||
function movementSpeed() { | ||
var speed = dragFree ? freeSpeed : snapSpeed; | ||
var type = isMouse ? 'mouse' : 'touch'; | ||
return speed[type]; | ||
} | ||
function dragForceBoost() { | ||
var boost = dragFree ? freeForceBoost : snapForceBoost; | ||
var type = isMouse ? 'mouse' : 'touch'; | ||
return boost[type]; | ||
} | ||
function seekTargetBy(force) { | ||
var scrollTo = params.scrollTo, | ||
scrollTarget = params.scrollTarget, | ||
index = params.index; | ||
var reachedLimit = limit.reachedAny(target.get() + force); | ||
var currentLocation = scrollTarget.byDistance(0, false); | ||
var targetChanged = currentLocation.index !== index.get(); | ||
var seekNext = !targetChanged && Math.abs(force) > dragThreshold; | ||
if (!dragFree && !reachedLimit && seekNext) { | ||
var indexDiff = Direction(force).get() * -1; | ||
var next = index.clone().add(indexDiff); | ||
scrollTo.index(next.get(), 0); | ||
} else { | ||
scrollTo.distance(force, !dragFree); | ||
} | ||
} | ||
function down(evt) { | ||
isMouse = evt.type === 'mousedown'; | ||
if (isMouse && evt.button !== 0) return; | ||
var isMoving = delta(target.get(), location.get()) >= 2; | ||
var clearPreventClick = isMouse || !isMoving; | ||
var isNotFocusNode = !isFocusNode(evt.target); | ||
var preventDefault = isMoving || isMouse && isNotFocusNode; | ||
pointerIsDown = true; | ||
dragTracker.pointerDown(evt); | ||
dragStartPoint.set(target); | ||
target.set(location); | ||
scrollBody.useDefaultMass().useSpeed(80); | ||
addInteractionEvents(); | ||
startScroll.set(dragTracker.readPoint(evt, scrollAxis)); | ||
startCross.set(dragTracker.readPoint(evt, crossAxis)); | ||
events.emit('pointerDown'); | ||
if (clearPreventClick) preventClick = false; | ||
if (preventDefault) evt.preventDefault(); | ||
} | ||
function move(evt) { | ||
if (!preventScroll && !isMouse) { | ||
var moveScroll = dragTracker.readPoint(evt, scrollAxis).get(); | ||
var moveCross = dragTracker.readPoint(evt, crossAxis).get(); | ||
var diffScroll = delta(moveScroll, startScroll.get()); | ||
var diffCross = delta(moveCross, startCross.get()); | ||
preventScroll = diffScroll > diffCross; | ||
if (!preventScroll && !preventClick) return up(); | ||
} | ||
var diff = dragTracker.pointerMove(evt); | ||
var reachedLimit = limit.reachedAny(location.get()); | ||
var resist = !params.loop && reachedLimit ? 2 : 1; | ||
if (!preventClick && diff) preventClick = true; | ||
animation.start(); | ||
target.add(diff / resist); | ||
evt.preventDefault(); | ||
} | ||
function up() { | ||
var force = dragTracker.pointerUp() * dragForceBoost(); | ||
var isMoving = delta(target.get(), dragStartPoint.get()) >= 0.5; | ||
if (isMoving && !isMouse) preventClick = true; | ||
isMouse = false; | ||
preventScroll = false; | ||
pointerIsDown = false; | ||
interactionEvents.removeAll(); | ||
scrollBody.useSpeed(movementSpeed()); | ||
seekTargetBy(force); | ||
events.emit('pointerUp'); | ||
} | ||
function delta(pointB, pointA) { | ||
return Math.abs(pointB - pointA); | ||
} | ||
function click(evt) { | ||
if (preventClick) evt.preventDefault(); | ||
} | ||
function clickAllowed() { | ||
return !preventClick; | ||
} | ||
function pointerDown() { | ||
return pointerIsDown; | ||
} | ||
var self = { | ||
addActivationEvents: addActivationEvents, | ||
clickAllowed: clickAllowed, | ||
pointerDown: pointerDown, | ||
removeActivationEvents: removeActivationEvents, | ||
removeInteractionEvents: removeInteractionEvents | ||
}; | ||
return self; | ||
} | ||
function DragTracker(params) { | ||
var axis = params.axis, | ||
pxToPercent = params.pxToPercent; | ||
var scrollAxis = axis.scroll; | ||
var coords = { | ||
x: 'clientX', | ||
y: 'clientY' | ||
}; | ||
var startDrag = Vector1D(0); | ||
var diffDrag = Vector1D(0); | ||
var lastDrag = Vector1D(0); | ||
var pointValue = Vector1D(0); | ||
var trackInterval = 10; | ||
var trackPoints = []; | ||
var trackTime = new Date().getTime(); | ||
var isMouse = false; | ||
function readPoint(evt, type) { | ||
isMouse = !evt.touches; | ||
var c = coords[type]; | ||
var value = isMouse ? evt[c] : evt.touches[0][c]; | ||
return pointValue.set(value); | ||
} | ||
function pointerDown(evt) { | ||
var point = readPoint(evt, scrollAxis); | ||
startDrag.set(point); | ||
lastDrag.set(point); | ||
return pxToPercent.measure(startDrag.get()); | ||
} | ||
function pointerMove(evt) { | ||
var point = readPoint(evt, scrollAxis); | ||
var time2 = new Date().getTime(); | ||
var time1 = trackTime; | ||
if (time2 - time1 >= trackInterval) { | ||
trackPoints.push(point.get()); | ||
trackTime = time2; | ||
} | ||
diffDrag.set(point).subtract(lastDrag); | ||
lastDrag.set(point); | ||
return pxToPercent.measure(diffDrag.get()); | ||
} | ||
function pointerUp() { | ||
var currentPoint = lastDrag.get(); | ||
var trackLength = isMouse ? 5 : 4; | ||
var point = trackPoints.slice(-trackLength).map(function (trackPoint) { | ||
return currentPoint - trackPoint; | ||
}).sort(function (p1, p2) { | ||
return Math.abs(p1) < Math.abs(p2) ? 1 : -1; | ||
})[0]; | ||
lastDrag.set(point || 0); | ||
trackPoints = []; | ||
return pxToPercent.measure(lastDrag.get()); | ||
} | ||
var self = { | ||
pointerDown: pointerDown, | ||
pointerMove: pointerMove, | ||
pointerUp: pointerUp, | ||
readPoint: readPoint | ||
}; | ||
return self; | ||
} | ||
function Limit(params) { | ||
var min = params.min, | ||
max = params.max; | ||
var loopLimits = { | ||
min: max, | ||
max: min | ||
}; | ||
var constrainLimits = { | ||
min: min, | ||
max: max | ||
}; | ||
var length = Math.abs(min - max); | ||
function reachedMin(n) { | ||
return n < min; | ||
} | ||
function reachedMax(n) { | ||
return n > max; | ||
} | ||
function reachedAny(n) { | ||
return reachedMin(n) || reachedMax(n); | ||
} | ||
function reachedWhich(n) { | ||
if (reachedMin(n)) return 'min'; | ||
if (reachedMax(n)) return 'max'; | ||
return ''; | ||
} | ||
function removeOffset(n) { | ||
if (min === max) return n; | ||
while (reachedMin(n)) { | ||
n += length; | ||
} | ||
while (reachedMax(n)) { | ||
n -= length; | ||
} | ||
return n; | ||
} | ||
function loop(n) { | ||
var which = reachedWhich(n); | ||
return which ? loopLimits[which] : n; | ||
} | ||
function constrain(n) { | ||
var which = reachedWhich(n); | ||
return which ? constrainLimits[which] : n; | ||
} | ||
var self = { | ||
constrain: constrain, | ||
length: length, | ||
loop: loop, | ||
max: max, | ||
min: min, | ||
reachedAny: reachedAny, | ||
reachedMax: reachedMax, | ||
reachedMin: reachedMin, | ||
removeOffset: removeOffset | ||
}; | ||
return self; | ||
} | ||
function PxToPercent(viewInPx) { | ||
var totalPercent = 100; | ||
function measure(n) { | ||
return n / viewInPx * totalPercent; | ||
} | ||
var self = { | ||
measure: measure, | ||
totalPercent: totalPercent | ||
}; | ||
return Object.freeze(self); | ||
} | ||
function map(value, iStart, iStop, oStart, oStop) { | ||
return oStart + (oStop - oStart) * ((value - iStart) / (iStop - iStart)); | ||
} | ||
function arrayFromCollection(nodeList) { | ||
return Array.prototype.slice.call(nodeList); | ||
} | ||
function debounce(callback, time) { | ||
var timeout = { | ||
id: 0 | ||
}; | ||
return function () { | ||
window.clearTimeout(timeout.id); | ||
timeout.id = window.setTimeout(callback, time) || 0; | ||
}; | ||
} | ||
function roundToDecimals(decimalPoints) { | ||
var pow = Math.pow(10, decimalPoints); | ||
return function (n) { | ||
return Math.round(n * pow) / pow; | ||
}; | ||
} | ||
function groupArray(array, size) { | ||
var groups = []; | ||
for (var i = 0; i < array.length; i += size) { | ||
groups.push(array.slice(i, i + size)); | ||
} | ||
return groups; | ||
} | ||
function arrayKeys(array) { | ||
return Object.keys(array).map(Number); | ||
} | ||
function removeClass(node, className) { | ||
var cl = node.classList; | ||
if (cl.contains(className)) cl.remove(className); | ||
} | ||
function addClass(node, className) { | ||
var cl = node.classList; | ||
if (!cl.contains(className)) cl.add(className); | ||
} | ||
function ScrollBody(params) { | ||
var location = params.location, | ||
speed = params.speed, | ||
mass = params.mass; | ||
var roundToTwoDecimals = roundToDecimals(2); | ||
var velocity = Vector1D(0); | ||
var acceleration = Vector1D(0); | ||
var attraction = Vector1D(0); | ||
var direction = Direction(0); | ||
var state = { | ||
speed: speed, | ||
mass: mass | ||
}; | ||
function update() { | ||
velocity.add(acceleration); | ||
location.add(velocity); | ||
acceleration.multiply(0); | ||
} | ||
function applyForce(v) { | ||
v.divide(state.mass); | ||
acceleration.add(v); | ||
} | ||
function seek(v) { | ||
attraction.set(v).subtract(location); | ||
var magnitude = attraction.get(); | ||
var m = map(magnitude, 0, 100, 0, state.speed); | ||
direction.set(attraction); | ||
attraction.normalize().multiply(m).subtract(velocity); | ||
applyForce(attraction); | ||
return self; | ||
} | ||
function settle(v) { | ||
var diff = v.get() - location.get(); | ||
var diffRounded = roundToTwoDecimals(diff); | ||
var hasSettled = !diffRounded; | ||
if (hasSettled) location.set(v); | ||
return hasSettled; | ||
} | ||
function useSpeed(n) { | ||
state.speed = n; | ||
return self; | ||
} | ||
function useDefaultSpeed() { | ||
useSpeed(speed); | ||
return self; | ||
} | ||
function useMass(n) { | ||
state.mass = n; | ||
return self; | ||
} | ||
function useDefaultMass() { | ||
useMass(mass); | ||
return self; | ||
} | ||
var self = { | ||
direction: direction, | ||
location: location, | ||
seek: seek, | ||
settle: settle, | ||
update: update, | ||
useDefaultMass: useDefaultMass, | ||
useDefaultSpeed: useDefaultSpeed, | ||
useMass: useMass, | ||
useSpeed: useSpeed | ||
}; | ||
return self; | ||
} | ||
function ScrollBounds(params) { | ||
var limit = params.limit, | ||
location = params.location, | ||
scrollBody = params.scrollBody, | ||
animation = params.animation; | ||
var min = limit.min, | ||
max = limit.max, | ||
reachedMin = limit.reachedMin, | ||
reachedMax = limit.reachedMax; | ||
var tolerance = 50; | ||
var disabled = false; | ||
var timeout = 0; | ||
function shouldConstrain(v) { | ||
if (disabled || timeout) return false; | ||
if (reachedMin(location.get())) return v.get() !== min; | ||
if (reachedMax(location.get())) return v.get() !== max; | ||
return false; | ||
} | ||
function constrain(v) { | ||
if (!shouldConstrain(v)) return; | ||
timeout = window.setTimeout(function () { | ||
var constraint = limit.constrain(v.get()); | ||
v.set(constraint); | ||
scrollBody.useSpeed(10).useMass(3); | ||
animation.start(); | ||
timeout = 0; | ||
}, tolerance); | ||
} | ||
function toggleActive(active) { | ||
disabled = !active; | ||
} | ||
var self = { | ||
constrain: constrain, | ||
toggleActive: toggleActive | ||
}; | ||
return self; | ||
} | ||
function ScrollContain(params) { | ||
var alignment = params.alignment, | ||
contentSize = params.contentSize, | ||
viewSize = params.viewSize; | ||
var scrollBounds = Limit({ | ||
min: -contentSize + viewSize, | ||
max: 0 | ||
}); | ||
var alignedWithinView = [alignment.measure(contentSize)]; | ||
var contentExceedsView = contentSize > viewSize; | ||
function findDuplicates(scrollSnaps) { | ||
var startSnap = scrollSnaps[0]; | ||
var endSnap = scrollSnaps[scrollSnaps.length - 1]; | ||
var min = scrollSnaps.lastIndexOf(startSnap) + 1; | ||
var max = scrollSnaps.indexOf(endSnap); | ||
return Limit({ | ||
min: min, | ||
max: max | ||
}); | ||
} | ||
function measure(scrollSnaps, trim) { | ||
var containedSnaps = scrollSnaps.map(scrollBounds.constrain); | ||
var _a = findDuplicates(containedSnaps), | ||
min = _a.min, | ||
max = _a.max; | ||
if (!contentExceedsView) return alignedWithinView; | ||
if (!trim) return containedSnaps; | ||
return containedSnaps.slice(min - 1, max + 1); | ||
} | ||
var self = { | ||
measure: measure | ||
}; | ||
return self; | ||
} | ||
function ScrollLimit(params) { | ||
var contentSize = params.contentSize, | ||
loop = params.loop; | ||
function measure(scrollSnaps) { | ||
var startSnap = scrollSnaps[0]; | ||
var endSnap = scrollSnaps[scrollSnaps.length - 1]; | ||
var min = loop ? startSnap - contentSize : endSnap; | ||
var max = startSnap; | ||
return Limit({ | ||
min: min, | ||
max: max | ||
}); | ||
} | ||
var self = { | ||
measure: measure | ||
}; | ||
return self; | ||
} | ||
function ScrollLooper(params) { | ||
var contentSize = params.contentSize, | ||
location = params.location, | ||
limit = params.limit, | ||
pxToPercent = params.pxToPercent; | ||
var min = limit.min + pxToPercent.measure(0.1); | ||
var max = limit.max + pxToPercent.measure(0.1); | ||
var _a = Limit({ | ||
min: min, | ||
max: max | ||
}), | ||
reachedMin = _a.reachedMin, | ||
reachedMax = _a.reachedMax; | ||
function shouldLoop(direction) { | ||
if (direction === 1) return reachedMax(location.get()); | ||
if (direction === -1) return reachedMin(location.get()); | ||
return false; | ||
} | ||
function loop(vectors, direction) { | ||
if (!shouldLoop(direction)) return; | ||
var loopDistance = contentSize * (direction * -1); | ||
vectors.forEach(function (v) { | ||
return v.add(loopDistance); | ||
}); | ||
} | ||
var self = { | ||
loop: loop | ||
}; | ||
return self; | ||
} | ||
function ScrollProgress(params) { | ||
var _a = params.limit, | ||
max = _a.max, | ||
scrollLength = _a.length; | ||
function get(n) { | ||
var currentLocation = n - max; | ||
return currentLocation / -scrollLength; | ||
} | ||
var self = { | ||
get: get | ||
}; | ||
return self; | ||
} | ||
function ScrollSnap(params) { | ||
var snapSizes = params.snapSizes, | ||
alignment = params.alignment, | ||
loop = params.loop; | ||
var alignments = snapSizes.map(alignment.measure); | ||
var distancesBetween = distancesBetweenScrollSnaps(); | ||
function distancesBetweenScrollSnaps() { | ||
var limit = Limit({ | ||
min: 0, | ||
max: snapSizes.length - 1 | ||
}); | ||
var counter = Counter({ | ||
limit: limit, | ||
start: 0, | ||
loop: loop | ||
}); | ||
return snapSizes.map(function (size, index) { | ||
var next = counter.set(index + 1).get(); | ||
return size + alignments[index] - alignments[next]; | ||
}); | ||
} | ||
function measure(index) { | ||
var sizes = distancesBetween.slice(0, index); | ||
return sizes.reduce(function (a, s) { | ||
return a - s; | ||
}, alignments[0]); | ||
} | ||
var self = { | ||
measure: measure | ||
}; | ||
return self; | ||
} | ||
function ScrollTarget(params) { | ||
var loop = params.loop, | ||
limit = params.limit, | ||
scrollSnaps = params.scrollSnaps, | ||
contentSize = params.contentSize; | ||
var reachedMax = limit.reachedMax, | ||
reachedAny = limit.reachedAny, | ||
removeOffset = limit.removeOffset; | ||
function minDistance(d1, d2) { | ||
return Math.abs(d1) < Math.abs(d2) ? d1 : d2; | ||
} | ||
function findTargetSnap(target) { | ||
var distance = removeOffset(target); | ||
var ascDiffsToSnaps = scrollSnaps.map(function (scrollSnap) { | ||
return scrollSnap - distance; | ||
}).map(function (diffToSnap) { | ||
return shortcut(diffToSnap, 0); | ||
}).map(function (diff, i) { | ||
return { | ||
diff: diff, | ||
index: i | ||
}; | ||
}).sort(function (d1, d2) { | ||
return Math.abs(d1.diff) - Math.abs(d2.diff); | ||
}); | ||
var index = ascDiffsToSnaps[0].index; | ||
return { | ||
index: index, | ||
distance: distance | ||
}; | ||
} | ||
function shortcut(target, direction) { | ||
var t1 = target; | ||
var t2 = target + contentSize; | ||
var t3 = target - contentSize; | ||
if (!loop) return t1; | ||
if (!direction) return minDistance(minDistance(t1, t2), t3); | ||
var shortest = minDistance(t1, direction === 1 ? t2 : t3); | ||
return Math.abs(shortest) * direction; | ||
} | ||
function findTargetIndex(target, index) { | ||
var reachedBound = !loop && reachedAny(target); | ||
if (!reachedBound) return index; | ||
var _a = params.index, | ||
min = _a.min, | ||
max = _a.max; | ||
return reachedMax(target) ? min : max; | ||
} | ||
function byIndex(index, direction) { | ||
var diffToSnap = scrollSnaps[index] - params.target.get(); | ||
var distance = shortcut(diffToSnap, direction); | ||
return { | ||
index: index, | ||
distance: distance | ||
}; | ||
} | ||
function byDistance(distance, snap) { | ||
var target = params.target.get() + distance; | ||
var targetSnap = findTargetSnap(target); | ||
var index = findTargetIndex(target, targetSnap.index); | ||
var reachedBound = !loop && reachedAny(target); | ||
if (!snap || reachedBound) return { | ||
index: index, | ||
distance: distance | ||
}; | ||
var diffToSnap = scrollSnaps[index] - targetSnap.distance; | ||
var snapDistance = distance + shortcut(diffToSnap, 0); | ||
return { | ||
index: index, | ||
distance: snapDistance | ||
}; | ||
} | ||
var self = { | ||
byDistance: byDistance, | ||
byIndex: byIndex, | ||
shortcut: shortcut | ||
}; | ||
return self; | ||
} | ||
function ScrollTo(params) { | ||
var indexCurrent = params.index, | ||
scrollTarget = params.scrollTarget, | ||
animation = params.animation; | ||
var indexPrevious = params.indexPrevious, | ||
events = params.events, | ||
targetDistance = params.target; | ||
function scrollTo(target) { | ||
var distanceDiff = target.distance; | ||
var indexDiff = target.index !== indexCurrent.get(); | ||
if (distanceDiff) { | ||
animation.start(); | ||
targetDistance.add(distanceDiff); | ||
} | ||
if (indexDiff) { | ||
indexPrevious.set(indexCurrent.get()); | ||
indexCurrent.set(target.index); | ||
events.emit('select'); | ||
} | ||
} | ||
function distance(n, snap) { | ||
var target = scrollTarget.byDistance(n, snap); | ||
scrollTo(target); | ||
} | ||
function index(n, direction) { | ||
var targetIndex = indexCurrent.clone().set(n); | ||
var target = scrollTarget.byIndex(targetIndex.get(), direction); | ||
scrollTo(target); | ||
} | ||
var self = { | ||
distance: distance, | ||
index: index | ||
}; | ||
return self; | ||
} | ||
function SlideLooper(params) { | ||
var axis = params.axis, | ||
containerLocation = params.location; | ||
var contentSize = params.contentSize, | ||
viewSize = params.viewSize, | ||
slideSizes = params.slideSizes, | ||
scrollSnaps = params.scrollSnaps; | ||
var ascItems = arrayKeys(slideSizes); | ||
var descItems = arrayKeys(slideSizes).reverse(); | ||
var loopPoints = startPoints().concat(endPoints()); | ||
var loopStyle = axis.scroll === 'x' ? 'left' : 'top'; | ||
function subtractItemSizes(indexes, from) { | ||
return indexes.reduce(function (a, i) { | ||
var size = slideSizes[i]; | ||
return a - size; | ||
}, from); | ||
} | ||
function loopItemsIn(sizeOfGap, indexes) { | ||
return indexes.reduce(function (a, i) { | ||
var gapLeft = subtractItemSizes(a, sizeOfGap); | ||
return gapLeft > 0 ? a.concat([i]) : a; | ||
}, []); | ||
} | ||
function loopStart(sizeOfGap, indexes, from) { | ||
return indexes.reduce(function (a, i) { | ||
var gapFilled = a + slideSizes[i]; | ||
return gapFilled < sizeOfGap ? gapFilled : a; | ||
}, from); | ||
} | ||
function loopPointFor(indexes, from, direction) { | ||
var slideCount = ascItems.length - 1; | ||
return subtractItemSizes(indexes.map(function (i) { | ||
return (i + direction) % slideCount; | ||
}), from); | ||
} | ||
function loopPointsFor(indexes, from, direction) { | ||
var ascIndexes = indexes.slice().sort(function (a, b) { | ||
return a - b; | ||
}); | ||
return ascIndexes.map(function (index, loopIndex) { | ||
var initial = contentSize * (!direction ? 0 : -1); | ||
var offset = contentSize * (!direction ? 1 : 0); | ||
var slidesInSpan = ascIndexes.slice(0, loopIndex); | ||
var point = loopPointFor(slidesInSpan, from, direction); | ||
var getTarget = function getTarget(location) { | ||
return location > point ? initial : offset; | ||
}; | ||
return { | ||
point: point, | ||
getTarget: getTarget, | ||
index: index, | ||
location: -1 | ||
}; | ||
}); | ||
} | ||
function startPoints() { | ||
var gap = scrollSnaps[0] - 1; | ||
var indexes = loopItemsIn(gap, descItems); | ||
var start = loopStart(gap, indexes, 0); | ||
return loopPointsFor(indexes, start, 1); | ||
} | ||
function endPoints() { | ||
var gap = viewSize - scrollSnaps[0] - 1; | ||
var indexes = loopItemsIn(gap, ascItems); | ||
var start = loopStart(contentSize, ascItems, -viewSize); | ||
return loopPointsFor(indexes, -start, 0); | ||
} | ||
function canLoop() { | ||
return loopPoints.every(function (_a) { | ||
var index = _a.index; | ||
var otherIndexes = ascItems.filter(function (i) { | ||
return i !== index; | ||
}); | ||
return subtractItemSizes(otherIndexes, viewSize) <= 0; | ||
}); | ||
} | ||
function loop(slides) { | ||
loopPoints.forEach(function (loopPoint) { | ||
var getTarget = loopPoint.getTarget, | ||
location = loopPoint.location, | ||
index = loopPoint.index; | ||
var target = getTarget(containerLocation.get()); | ||
if (target !== location) { | ||
slides[index].style[loopStyle] = target + "%"; | ||
loopPoint.location = target; | ||
} | ||
}); | ||
} | ||
function clear(slides) { | ||
loopPoints.forEach(function (_a) { | ||
var index = _a.index; | ||
slides[index].style[loopStyle] = ''; | ||
}); | ||
} | ||
var self = { | ||
canLoop: canLoop, | ||
clear: clear, | ||
loop: loop, | ||
loopPoints: loopPoints | ||
}; | ||
return self; | ||
} | ||
function SlidesInView(params) { | ||
var contentSize = params.contentSize, | ||
slideSizes = params.slideSizes, | ||
viewSize = params.viewSize; | ||
var inViewThreshold = params.inViewThreshold, | ||
loop = params.loop; | ||
var thresholds = slideSizes.map(function (s) { | ||
return s * inViewThreshold; | ||
}); | ||
var scrollSnaps = arrayKeys(slideSizes).map(scrollSnap); | ||
var pointsToCheck = concatSlidePoints(); | ||
function scrollSnap(index) { | ||
var span = slideSizes.slice(0, index); | ||
return span.reduce(function (a, s) { | ||
return a - s; | ||
}, 0); | ||
} | ||
function concatSlidePoints() { | ||
var offsets = loop ? [0, contentSize, -contentSize] : [0]; | ||
return offsets.map(slidePoints).reduce(function (a, b) { | ||
return a.concat(b); | ||
}, []); | ||
} | ||
function slidePoints(offset) { | ||
return scrollSnaps.map(function (snap, index) { | ||
return { | ||
start: snap - slideSizes[index] + thresholds[index] + offset, | ||
end: snap + viewSize - thresholds[index] + offset, | ||
index: index | ||
}; | ||
}); | ||
} | ||
function check(location) { | ||
return pointsToCheck.reduce(function (list, point) { | ||
var index = point.index, | ||
start = point.start, | ||
end = point.end; | ||
var inList = list.indexOf(index) !== -1; | ||
var inView = start < location && end > location; | ||
return !inList && inView ? list.concat([index]) : list; | ||
}, []); | ||
} | ||
var self = { | ||
check: check | ||
}; | ||
return self; | ||
} | ||
function Translate(params) { | ||
var axis = params.axis, | ||
container = params.container; | ||
var translates = { | ||
x: x, | ||
y: y | ||
}; | ||
var translateAxis = translates[axis.scroll]; | ||
var roundToTwoDecimals = roundToDecimals(2); | ||
var containerStyle = container.style; | ||
var disabled = false; | ||
var location = 0; | ||
function x(n) { | ||
return "translate3d(" + n + "%,0px,0px)"; | ||
} | ||
function y(n) { | ||
return "translate3d(0px," + n + "%,0px)"; | ||
} | ||
function to(v) { | ||
if (disabled) return; | ||
var target = roundToTwoDecimals(v.get()); | ||
if (location !== target) { | ||
getComputedStyle(container).transform; | ||
containerStyle.transform = translateAxis(target); | ||
location = target; | ||
} | ||
} | ||
function toggleActive(active) { | ||
disabled = !active; | ||
} | ||
function clear() { | ||
containerStyle.transform = ''; | ||
location = 0; | ||
} | ||
var self = { | ||
clear: clear, | ||
to: to, | ||
toggleActive: toggleActive | ||
}; | ||
return self; | ||
} | ||
function Engine(root, container, slides, options, events) { | ||
// Options | ||
var align = options.align, | ||
scrollAxis = options.axis, | ||
startIndex = options.startIndex, | ||
inViewThreshold = options.inViewThreshold, | ||
loop = options.loop, | ||
speed = options.speed, | ||
dragFree = options.dragFree, | ||
slidesToScroll = options.slidesToScroll, | ||
containScroll = options.containScroll; // Measurements | ||
var axis = Axis(scrollAxis); | ||
var pxToPercent = PxToPercent(axis.measure(container)); | ||
var viewSize = pxToPercent.totalPercent; | ||
var slideSizes = slides.map(axis.measure).map(pxToPercent.measure); | ||
var groupedSizes = groupArray(slideSizes, slidesToScroll); | ||
var snapSizes = groupedSizes.map(function (g) { | ||
return g.reduce(function (a, s) { | ||
return a + s; | ||
}); | ||
}); | ||
var snapIndexes = arrayKeys(snapSizes); | ||
var contentSize = slideSizes.reduce(function (a, s) { | ||
return a + s; | ||
}, 0); | ||
var alignment = Alignment({ | ||
align: align, | ||
viewSize: viewSize | ||
}); | ||
var scrollSnap = ScrollSnap({ | ||
snapSizes: snapSizes, | ||
alignment: alignment, | ||
loop: loop | ||
}); | ||
var defaultSnaps = snapIndexes.map(scrollSnap.measure); | ||
var contain = ScrollContain({ | ||
alignment: alignment, | ||
contentSize: contentSize, | ||
viewSize: viewSize | ||
}); | ||
var shouldContain = !loop && containScroll !== ''; | ||
var trimSnaps = containScroll === 'trimSnaps'; | ||
var containedSnaps = contain.measure(defaultSnaps, trimSnaps); | ||
var scrollSnaps = shouldContain ? containedSnaps : defaultSnaps; // Index | ||
var indexSpan = Limit({ | ||
min: 0, | ||
max: scrollSnaps.length - 1 | ||
}); | ||
var index = Counter({ | ||
limit: indexSpan, | ||
start: startIndex, | ||
loop: loop | ||
}); | ||
var indexPrevious = index.clone(); // ScrollLimit | ||
var scrollLimit = ScrollLimit({ | ||
loop: loop, | ||
contentSize: contentSize | ||
}); | ||
var limit = scrollLimit.measure(scrollSnaps); // Draw | ||
var update = function update() { | ||
engine.scrollBody.seek(target).update(); | ||
var settled = engine.scrollBody.settle(target); | ||
if (!dragHandler.pointerDown()) { | ||
if (!loop) engine.scrollBounds.constrain(target); | ||
if (settled) { | ||
engine.animation.stop(); | ||
events.emit('settle'); | ||
} | ||
} | ||
if (loop) { | ||
var direction = engine.scrollBody.direction.get(); | ||
engine.scrollLooper.loop(loopVectors, direction); | ||
engine.slideLooper.loop(slides); | ||
} | ||
if (!settled) events.emit('scroll'); | ||
engine.translate.to(engine.scrollBody.location); | ||
engine.animation.proceed(); | ||
}; // Shared | ||
var animation = Animation(update); | ||
var startLocation = scrollSnaps[index.get()]; | ||
var location = Vector1D(startLocation); | ||
var target = Vector1D(startLocation); | ||
var loopVectors = [location, target]; | ||
var scrollBody = ScrollBody({ | ||
location: location, | ||
speed: speed, | ||
mass: 1 | ||
}); | ||
var scrollTarget = ScrollTarget({ | ||
contentSize: contentSize, | ||
index: index, | ||
limit: limit, | ||
loop: loop, | ||
scrollSnaps: scrollSnaps, | ||
target: target | ||
}); | ||
var scrollTo = ScrollTo({ | ||
animation: animation, | ||
events: events, | ||
index: index, | ||
indexPrevious: indexPrevious, | ||
scrollTarget: scrollTarget, | ||
target: target | ||
}); // DragHandler | ||
var dragHandler = DragHandler({ | ||
animation: animation, | ||
axis: axis, | ||
dragFree: dragFree, | ||
dragTracker: DragTracker({ | ||
axis: axis, | ||
pxToPercent: pxToPercent | ||
}), | ||
element: root, | ||
events: events, | ||
index: index, | ||
limit: limit, | ||
location: location, | ||
loop: loop, | ||
scrollBody: scrollBody, | ||
scrollTo: scrollTo, | ||
scrollTarget: scrollTarget, | ||
target: target | ||
}); // Slider | ||
var engine = { | ||
animation: animation, | ||
axis: axis, | ||
dragHandler: dragHandler, | ||
pxToPercent: pxToPercent, | ||
index: index, | ||
indexPrevious: indexPrevious, | ||
limit: limit, | ||
location: location, | ||
options: options, | ||
scrollBody: scrollBody, | ||
scrollBounds: ScrollBounds({ | ||
animation: animation, | ||
limit: limit, | ||
location: location, | ||
scrollBody: scrollBody | ||
}), | ||
scrollLooper: ScrollLooper({ | ||
contentSize: contentSize, | ||
limit: limit, | ||
location: location, | ||
pxToPercent: pxToPercent | ||
}), | ||
scrollProgress: ScrollProgress({ | ||
limit: limit | ||
}), | ||
scrollSnaps: scrollSnaps, | ||
scrollTarget: scrollTarget, | ||
scrollTo: scrollTo, | ||
slideLooper: SlideLooper({ | ||
axis: axis, | ||
contentSize: contentSize, | ||
location: location, | ||
scrollSnaps: scrollSnaps, | ||
slideSizes: slideSizes, | ||
viewSize: viewSize | ||
}), | ||
slidesInView: SlidesInView({ | ||
contentSize: contentSize, | ||
inViewThreshold: inViewThreshold, | ||
loop: loop, | ||
slideSizes: slideSizes, | ||
viewSize: viewSize | ||
}), | ||
snapIndexes: snapIndexes, | ||
target: target, | ||
translate: Translate({ | ||
axis: axis, | ||
container: container | ||
}) | ||
}; | ||
return engine; | ||
} | ||
function EventEmitter() { | ||
var listeners = { | ||
destroy: [], | ||
pointerDown: [], | ||
pointerUp: [], | ||
init: [], | ||
reInit: [], | ||
resize: [], | ||
scroll: [], | ||
select: [], | ||
settle: [] | ||
}; | ||
function emit(evt) { | ||
listeners[evt].forEach(function (e) { | ||
return e(evt); | ||
}); | ||
return self; | ||
} | ||
function on(evt, cb) { | ||
listeners[evt] = listeners[evt].concat([cb]); | ||
return self; | ||
} | ||
function off(evt, cb) { | ||
listeners[evt] = listeners[evt].filter(function (e) { | ||
return e !== cb; | ||
}); | ||
return self; | ||
} | ||
var self = { | ||
emit: emit, | ||
off: off, | ||
on: on | ||
}; | ||
return self; | ||
} | ||
var defaultOptions = { | ||
align: 'center', | ||
axis: 'x', | ||
containScroll: '', | ||
containerSelector: '*', | ||
dragFree: false, | ||
draggable: true, | ||
draggableClass: 'is-draggable', | ||
draggingClass: 'is-dragging', | ||
inViewThreshold: 0, | ||
loop: false, | ||
selectedClass: 'is-selected', | ||
slidesToScroll: 1, | ||
speed: 10, | ||
startIndex: 0 | ||
}; | ||
function EmblaCarousel(sliderRoot, userOptions) { | ||
if (userOptions === void 0) { | ||
userOptions = {}; | ||
} | ||
var events = EventEmitter(); | ||
var eventStore = EventStore(); | ||
var debouncedResize = debounce(resize, 500); | ||
var reInit = reActivate; | ||
var on = events.on, | ||
off = events.off; | ||
var engine; | ||
var activated = false; | ||
var options = _extends({}, defaultOptions); | ||
var containerSize = 0; | ||
var container; | ||
var slides; | ||
activate(userOptions); | ||
function storeElements() { | ||
if (!sliderRoot) throw new Error('Missing root node 😢'); | ||
var selector = options.containerSelector; | ||
var sliderContainer = sliderRoot.querySelector(selector); | ||
if (!sliderContainer) throw new Error('Missing container node 😢'); | ||
container = sliderContainer; | ||
slides = arrayFromCollection(container.children); | ||
} | ||
function activate(partialOptions) { | ||
if (partialOptions === void 0) { | ||
partialOptions = {}; | ||
} | ||
storeElements(); | ||
options = _extends(options, partialOptions); | ||
engine = Engine(sliderRoot, container, slides, options, events); | ||
var axis = engine.axis, | ||
scrollBody = engine.scrollBody, | ||
translate = engine.translate, | ||
dragHandler = engine.dragHandler, | ||
slideLooper = engine.slideLooper; | ||
var loop = options.loop, | ||
draggable = options.draggable, | ||
draggableClass = options.draggableClass, | ||
selectedClass = options.selectedClass, | ||
draggingClass = options.draggingClass; | ||
containerSize = axis.measure(container); | ||
eventStore.add(window, 'resize', debouncedResize); | ||
translate.to(scrollBody.location); | ||
slides.forEach(slideFocusEvent); | ||
dragHandler.addActivationEvents(); | ||
if (loop) { | ||
if (!slideLooper.canLoop()) return reActivate({ | ||
loop: false | ||
}); | ||
slideLooper.loop(slides); | ||
} | ||
if (draggable) { | ||
if (draggableClass) { | ||
addClass(sliderRoot, draggableClass); | ||
} | ||
if (draggingClass) { | ||
events.on('pointerDown', toggleDraggingClass); | ||
events.on('pointerUp', toggleDraggingClass); | ||
} | ||
} else { | ||
events.on('pointerDown', dragHandler.removeInteractionEvents); | ||
} | ||
if (selectedClass) { | ||
toggleSelectedClass(); | ||
events.on('select', toggleSelectedClass); | ||
events.on('pointerUp', toggleSelectedClass); | ||
} | ||
if (!activated) { | ||
setTimeout(function () { | ||
return events.emit('init'); | ||
}, 0); | ||
activated = true; | ||
} | ||
} | ||
function toggleDraggingClass(evt) { | ||
var draggingClass = options.draggingClass; | ||
if (evt === 'pointerDown') addClass(sliderRoot, draggingClass);else removeClass(sliderRoot, draggingClass); | ||
} | ||
function toggleSelectedClass() { | ||
var selectedClass = options.selectedClass; | ||
var inView = slidesInView(true); | ||
var notInView = slidesNotInView(true); | ||
notInView.forEach(function (i) { | ||
return removeClass(slides[i], selectedClass); | ||
}); | ||
inView.forEach(function (i) { | ||
return addClass(slides[i], selectedClass); | ||
}); | ||
} | ||
function slideFocusEvent(slide, index) { | ||
var focus = function focus() { | ||
var groupIndex = Math.floor(index / options.slidesToScroll); | ||
var selectedGroup = index ? groupIndex : index; | ||
sliderRoot.scrollLeft = 0; | ||
scrollTo(selectedGroup); | ||
}; | ||
eventStore.add(slide, 'focus', focus, true); | ||
} | ||
function reActivate(partialOptions) { | ||
if (partialOptions === void 0) { | ||
partialOptions = {}; | ||
} | ||
var startIndex = engine.index.get(); | ||
var newOptions = _extends({ | ||
startIndex: startIndex | ||
}, partialOptions); | ||
deActivate(); | ||
activate(newOptions); | ||
events.emit('reInit'); | ||
} | ||
function deActivate() { | ||
var selectedClass = options.selectedClass, | ||
draggableClass = options.draggableClass; | ||
engine.dragHandler.removeActivationEvents(); | ||
engine.dragHandler.removeInteractionEvents(); | ||
engine.animation.stop(); | ||
eventStore.removeAll(); | ||
engine.translate.clear(); | ||
engine.slideLooper.clear(slides); | ||
removeClass(sliderRoot, draggableClass); | ||
slides.forEach(function (s) { | ||
return removeClass(s, selectedClass); | ||
}); | ||
events.off('select', toggleSelectedClass); | ||
events.off('pointerUp', toggleSelectedClass); | ||
events.off('pointerDown', toggleDraggingClass); | ||
events.off('pointerUp', toggleDraggingClass); | ||
} | ||
function destroy() { | ||
if (!activated) return; | ||
deActivate(); | ||
activated = false; | ||
engine = {}; | ||
events.emit('destroy'); | ||
} | ||
function resize() { | ||
var newContainerSize = engine.axis.measure(container); | ||
if (containerSize !== newContainerSize) reActivate(); | ||
events.emit('resize'); | ||
} | ||
function slidesInView(target) { | ||
if (target === void 0) { | ||
target = false; | ||
} | ||
var location = engine[target ? 'target' : 'location'].get(); | ||
var type = options.loop ? 'removeOffset' : 'constrain'; | ||
return engine.slidesInView.check(engine.limit[type](location)); | ||
} | ||
function slidesNotInView(target) { | ||
if (target === void 0) { | ||
target = false; | ||
} | ||
var inView = slidesInView(target); | ||
return engine.snapIndexes.filter(function (i) { | ||
return inView.indexOf(i) === -1; | ||
}); | ||
} | ||
function scrollSnapList() { | ||
var getScrollProgress = engine.scrollProgress.get; | ||
return engine.scrollSnaps.map(getScrollProgress); | ||
} | ||
function scrollTo(index) { | ||
engine.scrollBody.useDefaultMass().useDefaultSpeed(); | ||
engine.scrollTo.index(index, 0); | ||
} | ||
function scrollNext() { | ||
var next = engine.index.clone().add(1); | ||
engine.scrollBody.useDefaultMass().useDefaultSpeed(); | ||
engine.scrollTo.index(next.get(), -1); | ||
} | ||
function scrollPrev() { | ||
var prev = engine.index.clone().add(-1); | ||
engine.scrollBody.useDefaultMass().useDefaultSpeed(); | ||
engine.scrollTo.index(prev.get(), 1); | ||
} | ||
function canScrollPrev() { | ||
var index = engine.index; | ||
return options.loop || index.get() !== index.min; | ||
} | ||
function canScrollNext() { | ||
var index = engine.index; | ||
return options.loop || index.get() !== index.max; | ||
} | ||
function scrollProgress() { | ||
var location = engine.location.get(); | ||
return engine.scrollProgress.get(location); | ||
} | ||
function selectedScrollSnap() { | ||
return engine.index.get(); | ||
} | ||
function previousScrollSnap() { | ||
return engine.indexPrevious.get(); | ||
} | ||
function clickAllowed() { | ||
return engine.dragHandler.clickAllowed(); | ||
} | ||
function dangerouslyGetEngine() { | ||
return engine; | ||
} | ||
function containerNode() { | ||
return container; | ||
} | ||
function slideNodes() { | ||
return slides; | ||
} | ||
var self = { | ||
canScrollNext: canScrollNext, | ||
canScrollPrev: canScrollPrev, | ||
clickAllowed: clickAllowed, | ||
containerNode: containerNode, | ||
dangerouslyGetEngine: dangerouslyGetEngine, | ||
destroy: destroy, | ||
off: off, | ||
on: on, | ||
previousScrollSnap: previousScrollSnap, | ||
reInit: reInit, | ||
scrollNext: scrollNext, | ||
scrollPrev: scrollPrev, | ||
scrollProgress: scrollProgress, | ||
scrollSnapList: scrollSnapList, | ||
scrollTo: scrollTo, | ||
selectedScrollSnap: selectedScrollSnap, | ||
slideNodes: slideNodes, | ||
slidesInView: slidesInView, | ||
slidesNotInView: slidesNotInView | ||
}; | ||
return self; | ||
} | ||
module.exports = EmblaCarousel; | ||
//# sourceMappingURL=embla-carousel.js.map |
@@ -1,2 +0,3 @@ | ||
export { default } from './vanilla'; | ||
export { useEmblaCarousel } from './react'; | ||
import EmblaCarousel from './vanilla'; | ||
import { useEmblaCarousel } from './react'; | ||
export { EmblaCarousel, useEmblaCarousel }; |
{ | ||
"name": "embla-carousel", | ||
"version": "3.0.7", | ||
"version": "3.0.8", | ||
"private": false, | ||
@@ -17,6 +17,15 @@ "author": "David Cetinkaya <david.o.cetinkaya@gmail.com>", | ||
"license": "MIT", | ||
"main": "lib/index.cjs.js", | ||
"jsnext:main": "lib/index.cjs.js", | ||
"module": "lib/index.cjs.js", | ||
"types": "lib/index.d.ts", | ||
"main": "./lib/index.js", | ||
"module": "./lib/es/index.js", | ||
"types": "./lib/index.d.ts", | ||
"exports": { | ||
".": { | ||
"node": { | ||
"require": "./lib/index.js", | ||
"import": "./lib/es/index.js" | ||
}, | ||
"default": "./lib/embla-carousel.browser.js" | ||
}, | ||
"./lib/": "./lib/" | ||
}, | ||
"repository": { | ||
@@ -23,0 +32,0 @@ "type": "git", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
478159
47
3635