embla-carousel-fade
Advanced tools
Comparing version 8.3.1 to 8.4.0
@@ -14,3 +14,2 @@ 'use strict'; | ||
const fadeFriction = 0.68; | ||
const timeStep = 1000 / 60; | ||
let emblaApi; | ||
@@ -182,5 +181,4 @@ let opacities = []; | ||
} = emblaApi.internalEngine(); | ||
const fixedDeltaTimeSeconds = timeStep / 1000; | ||
const pointerDown = dragHandler.pointerDown(); | ||
const velocity = scrollBody.velocity() * fixedDeltaTimeSeconds; | ||
const velocity = scrollBody.velocity(); | ||
const duration = scrollBody.duration(); | ||
@@ -187,0 +185,0 @@ const fadeIndex = getFadeIndex(); |
{ | ||
"name": "embla-carousel-fade", | ||
"version": "8.3.1", | ||
"version": "8.4.0", | ||
"author": "David Jerleke", | ||
@@ -51,3 +51,3 @@ "description": "A fade plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.3.1" | ||
"embla-carousel": "8.4.0" | ||
}, | ||
@@ -54,0 +54,0 @@ "main": "embla-carousel-fade.cjs.js", |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselFade=t()}(this,(function(){"use strict";function n(n,t,e){return Math.min(Math.max(n,t),e)}function t(n){return"number"==typeof n&&!isNaN(n)}function e(e={}){const o=1,i=0,r=.68,s=1e3/60;let l,c,a,f,d=[],u=0,p=0,g=0,y=!1;function E(){v(l.selectedScrollSnap(),o)}function S(){y=!1}function h(){y=!1,u=0,p=0}function m(){const n=l.internalEngine().scrollBody.duration();p=n?0:o,y=!0,n||E()}function b(n){const{scrollSnaps:e,location:o,target:i}=l.internalEngine();!t(n)||d[n]<.5||(o.set(e[n]),i.set(o))}function v(t,e){l.scrollSnapList().forEach(((r,s)=>{const c=Math.abs(e),a=d[s],f=s===t,p=n(f?a+c:a-c,i,o);d[s]=p;const E=f&&y,S=l.previousScrollSnap();E&&(d[S]=1-p),f&&function(n,t){const{index:e,dragHandler:o,scrollSnaps:i}=l.internalEngine(),r=o.pointerDown(),s=1/(i.length-1);let c=n,a=r?l.selectedScrollSnap():l.previousScrollSnap();if(r&&c===a){const n=-1*Math.sign(u);c=a,a=e.clone().set(a).add(n).get()}const f=a*s,d=(c-a)*s;g=f+d*t}(t,p),function(n){const t=l.internalEngine().slideRegistry[n],{scrollSnaps:e,containerRect:o}=l.internalEngine(),r=d[n];t.forEach((t=>{const s=l.slideNodes()[t].style,c=parseFloat(r.toFixed(2)),a=c>i,f=function(n){const{axis:t}=l.internalEngine();return`translate${t.scroll.toUpperCase()}(${t.direction(n)}px)`}(a?e[n]:o.width+2);a&&(s.transform=f),s.opacity=c.toString(),s.pointerEvents=r>.5?"auto":"none",a||(s.transform=f)}))}(s)}))}function x(){const{dragHandler:n,index:t,scrollBody:e}=l.internalEngine(),o=l.selectedScrollSnap();if(!n.pointerDown())return o;const i=Math.sign(e.velocity()),r=Math.sign(u),s=t.clone().set(o).add(-1*i).get();return i&&r?r===i?s:o:null}function M(){const{target:n,location:e}=l.internalEngine(),i=n.get()-e.get(),a=Math.abs(i)>=1,f=x(),g=!t(f);return function(n){const{dragHandler:e,scrollBody:i}=n.internalEngine(),l=s/1e3,a=e.pointerDown(),f=i.velocity()*l,g=i.duration(),y=x(),E=!t(y);if(a){if(!f)return;u+=f,p=Math.abs(f/c),b(y)}if(!a){if(!g||E)return;p+=(o-d[y])/g,p*=r}E||v(y,p)}(l),!g&&!a&&d[f]>.999}function w(){return g}return{name:"fade",options:e,init:function(t){l=t;const e=l.selectedScrollSnap(),{scrollBody:r,containerRect:s,axis:u}=l.internalEngine(),p=u.measureSize(s);c=n(.75*p,200,500),y=!1,d=l.scrollSnapList().map(((n,t)=>t===e?o:i)),a=r.settled,f=l.scrollProgress,r.settled=M,l.scrollProgress=w,l.on("select",m).on("slideFocus",E).on("pointerDown",h).on("pointerUp",S),function(){const{translate:n,slideLooper:t}=l.internalEngine();n.clear(),n.toggleActive(!1),t.loopPoints.forEach((({translate:n})=>{n.clear(),n.toggleActive(!1)}))}(),E()},destroy:function(){const{scrollBody:n}=l.internalEngine();n.settled=a,l.scrollProgress=f,l.off("select",m).off("slideFocus",E).off("pointerDown",h).off("pointerUp",S),l.slideNodes().forEach((n=>{const t=n.style;t.opacity="",t.transform="",t.pointerEvents="",n.getAttribute("style")||n.removeAttribute("style")}))}}}return e.globalOptions=void 0,e})); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselFade=t()}(this,(function(){"use strict";function n(n,t,e){return Math.min(Math.max(n,t),e)}function t(n){return"number"==typeof n&&!isNaN(n)}function e(e={}){const o=1,i=0,r=.68;let s,l,c,a,f=[],d=0,u=0,p=0,g=!1;function y(){b(s.selectedScrollSnap(),o)}function E(){g=!1}function S(){g=!1,d=0,u=0}function h(){const n=s.internalEngine().scrollBody.duration();u=n?0:o,g=!0,n||y()}function m(n){const{scrollSnaps:e,location:o,target:i}=s.internalEngine();!t(n)||f[n]<.5||(o.set(e[n]),i.set(o))}function b(t,e){s.scrollSnapList().forEach(((r,l)=>{const c=Math.abs(e),a=f[l],u=l===t,y=n(u?a+c:a-c,i,o);f[l]=y;const E=u&&g,S=s.previousScrollSnap();E&&(f[S]=1-y),u&&function(n,t){const{index:e,dragHandler:o,scrollSnaps:i}=s.internalEngine(),r=o.pointerDown(),l=1/(i.length-1);let c=n,a=r?s.selectedScrollSnap():s.previousScrollSnap();if(r&&c===a){const n=-1*Math.sign(d);c=a,a=e.clone().set(a).add(n).get()}const f=a*l,u=(c-a)*l;p=f+u*t}(t,y),function(n){const t=s.internalEngine().slideRegistry[n],{scrollSnaps:e,containerRect:o}=s.internalEngine(),r=f[n];t.forEach((t=>{const l=s.slideNodes()[t].style,c=parseFloat(r.toFixed(2)),a=c>i,f=function(n){const{axis:t}=s.internalEngine();return`translate${t.scroll.toUpperCase()}(${t.direction(n)}px)`}(a?e[n]:o.width+2);a&&(l.transform=f),l.opacity=c.toString(),l.pointerEvents=r>.5?"auto":"none",a||(l.transform=f)}))}(l)}))}function v(){const{dragHandler:n,index:t,scrollBody:e}=s.internalEngine(),o=s.selectedScrollSnap();if(!n.pointerDown())return o;const i=Math.sign(e.velocity()),r=Math.sign(d),l=t.clone().set(o).add(-1*i).get();return i&&r?r===i?l:o:null}function x(){const{target:n,location:e}=s.internalEngine(),i=n.get()-e.get(),c=Math.abs(i)>=1,a=v(),p=!t(a);return function(n){const{dragHandler:e,scrollBody:i}=n.internalEngine(),s=e.pointerDown(),c=i.velocity(),a=i.duration(),p=v(),g=!t(p);if(s){if(!c)return;d+=c,u=Math.abs(c/l),m(p)}if(!s){if(!a||g)return;u+=(o-f[p])/a,u*=r}g||b(p,u)}(s),!p&&!c&&f[a]>.999}function M(){return p}return{name:"fade",options:e,init:function(t){s=t;const e=s.selectedScrollSnap(),{scrollBody:r,containerRect:d,axis:u}=s.internalEngine(),p=u.measureSize(d);l=n(.75*p,200,500),g=!1,f=s.scrollSnapList().map(((n,t)=>t===e?o:i)),c=r.settled,a=s.scrollProgress,r.settled=x,s.scrollProgress=M,s.on("select",h).on("slideFocus",y).on("pointerDown",S).on("pointerUp",E),function(){const{translate:n,slideLooper:t}=s.internalEngine();n.clear(),n.toggleActive(!1),t.loopPoints.forEach((({translate:n})=>{n.clear(),n.toggleActive(!1)}))}(),y()},destroy:function(){const{scrollBody:n}=s.internalEngine();n.settled=c,s.scrollProgress=a,s.off("select",h).off("slideFocus",y).off("pointerDown",S).off("pointerUp",E),s.slideNodes().forEach((n=>{const t=n.style;t.opacity="",t.transform="",t.pointerEvents="",n.getAttribute("style")||n.removeAttribute("style")}))}}}return e.globalOptions=void 0,e})); |
@@ -12,3 +12,2 @@ function clampNumber(number, min, max) { | ||
const fadeFriction = 0.68; | ||
const timeStep = 1000 / 60; | ||
let emblaApi; | ||
@@ -180,5 +179,4 @@ let opacities = []; | ||
} = emblaApi.internalEngine(); | ||
const fixedDeltaTimeSeconds = timeStep / 1000; | ||
const pointerDown = dragHandler.pointerDown(); | ||
const velocity = scrollBody.velocity() * fixedDeltaTimeSeconds; | ||
const velocity = scrollBody.velocity(); | ||
const duration = scrollBody.duration(); | ||
@@ -185,0 +183,0 @@ const fadeIndex = getFadeIndex(); |
{ | ||
"name": "embla-carousel-fade", | ||
"version": "8.3.1", | ||
"version": "8.4.0", | ||
"author": "David Jerleke", | ||
@@ -51,3 +51,3 @@ "description": "A fade plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.3.1" | ||
"embla-carousel": "8.4.0" | ||
}, | ||
@@ -54,0 +54,0 @@ "module": "embla-carousel-fade.esm.js", |
{ | ||
"name": "embla-carousel-fade", | ||
"version": "8.3.1", | ||
"version": "8.4.0", | ||
"author": "David Jerleke", | ||
@@ -62,3 +62,3 @@ "description": "A fade plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.3.1" | ||
"embla-carousel": "8.4.0" | ||
}, | ||
@@ -65,0 +65,0 @@ "exports": { |
@@ -112,2 +112,4 @@ <br /> | ||
<img src="https://avatars2.githubusercontent.com/u/3440094?s=120&v=4" title="wopian" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/nikrowell"> | ||
<img src="https://avatars2.githubusercontent.com/u/260039?s=120&v=4" title="nikrowell" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/horseeyephil"> | ||
@@ -141,6 +143,6 @@ <img src="https://avatars2.githubusercontent.com/u/32337092?s=120&v=4" title="horseeyephil" width="50" height="50" style="max-width: 100%" /> | ||
<img src="https://avatars2.githubusercontent.com/u/9334305?s=120&v=4" title="silllli" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/nikrowell"> | ||
<img src="https://avatars2.githubusercontent.com/u/260039?s=120&v=4" title="nikrowell" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/mujahidfa"> | ||
<img src="https://avatars2.githubusercontent.com/u/17759705?s=120&v=4" title="mujahidfa" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/Mitch-At-Work"> | ||
<img src="https://avatars2.githubusercontent.com/u/99835933?s=120&v=4" title="Mitch-At-Work" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/romellem"> | ||
@@ -147,0 +149,0 @@ <img src="https://avatars2.githubusercontent.com/u/8504000?s=120&v=4" title="romellem" width="50" height="50" style="max-width: 100%" /> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
230
76423
517