embla-carousel-auto-scroll
Advanced tools
Comparing version 8.0.0 to 8.0.1
@@ -69,8 +69,6 @@ 'use strict'; | ||
} | ||
if (options.playOnInit) { | ||
emblaApi.on('init', startScroll).on('reInit', startScroll); | ||
} | ||
if (options.playOnInit) startScroll(); | ||
} | ||
function destroy() { | ||
emblaApi.off('init', startScroll).off('reInit', startScroll).off('pointerDown', stopScroll).off('pointerUp', startScrollOnSettle).off('settle', onSettle); | ||
emblaApi.off('pointerDown', stopScroll).off('pointerUp', startScrollOnSettle).off('settle', onSettle); | ||
stopScroll(); | ||
@@ -77,0 +75,0 @@ destroyed = true; |
{ | ||
"name": "embla-carousel-auto-scroll", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"author": "David Jerleke", | ||
@@ -51,3 +51,3 @@ "description": "An auto scroll plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.0.0" | ||
"embla-carousel": "8.0.1" | ||
}, | ||
@@ -54,0 +54,0 @@ "main": "embla-carousel-auto-scroll.cjs.js", |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).EmblaCarouselAutoScroll=n()}(this,(function(){"use strict";const t={direction:"forward",speed:2,startDelay:1e3,active:!0,breakpoints:{},playOnInit:!0,stopOnFocusIn:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,rootNode:null};function n(o={}){let e,i,r,s,c,l=!1,a=!0,u=0;function d(){if(r||l)return;if(!a)return;i.emit("autoScroll:play");const t=i.internalEngine(),{ownerWindow:n}=t;u=n.setTimeout((()=>{t.scrollBody=function(t){const{location:n,target:o,scrollTarget:r,index:s,indexPrevious:c,limit:{reachedMin:l,reachedMax:a,constrain:u},options:{loop:d}}=t,p="forward"===e.direction?-1:1,g=()=>S;let y=0,m=0,O=n.get(),I=0,w=!1;function b(){let t=0;y=p*e.speed,O+=y,n.add(y),o.set(n),t=O-I,m=Math.sign(t),I=O;const g=r.byDistance(0,!1).index;s.get()!==g&&(c.set(s.get()),s.set(g),i.emit("select"));const b="forward"===e.direction?l(n.get()):a(n.get());if(!d&&b){w=!0;const t=u(n.get());n.set(t),o.set(n),f()}return S}const S={direction:()=>m,duration:()=>-1,velocity:()=>y,settled:()=>w,seek:b,useBaseFriction:g,useBaseDuration:g,useFriction:g,useDuration:g};return S}(t),t.animation.start()}),s),l=!0}function f(){if(r||!l)return;i.emit("autoScroll:stop");const t=i.internalEngine(),{ownerWindow:n}=t;t.scrollBody=c,n.clearTimeout(u),u=0,l=!1}function p(){a&&d(),i.off("settle",p)}function g(){i.on("settle",p)}return{name:"autoScroll",options:o,init:function(l,u){i=l;const{mergeOptions:p,optionsAtMedia:y}=u,m=p(t,n.globalOptions),O=p(m,o);if(e=y(O),i.scrollSnapList().length<=1)return;s=e.startDelay,r=!1,c=i.internalEngine().scrollBody;const{eventStore:I}=i.internalEngine(),w=i.rootNode(),b=e.rootNode&&e.rootNode(w)||w,S=i.containerNode();i.on("pointerDown",f),e.stopOnInteraction||i.on("pointerUp",g),e.stopOnMouseEnter&&(I.add(b,"mouseenter",(()=>{a=!1,f()})),e.stopOnInteraction||I.add(b,"mouseleave",(()=>{a=!0,d()}))),e.stopOnFocusIn&&(I.add(S,"focusin",(()=>{f(),i.scrollTo(i.selectedScrollSnap(),!0)})),e.stopOnInteraction||I.add(S,"focusout",d)),e.playOnInit&&i.on("init",d).on("reInit",d)},destroy:function(){i.off("init",d).off("reInit",d).off("pointerDown",f).off("pointerUp",g).off("settle",p),f(),r=!0,l=!1},play:function(t){void 0!==t&&(s=t),a=!0,d()},stop:function(){l&&f()},reset:function(){l&&(f(),g())},isPlaying:function(){return l}}}return n.globalOptions=void 0,n})); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).EmblaCarouselAutoScroll=n()}(this,(function(){"use strict";const t={direction:"forward",speed:2,startDelay:1e3,active:!0,breakpoints:{},playOnInit:!0,stopOnFocusIn:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,rootNode:null};function n(o={}){let e,i,r,s,c,l=!1,a=!0,u=0;function d(){if(r||l)return;if(!a)return;i.emit("autoScroll:play");const t=i.internalEngine(),{ownerWindow:n}=t;u=n.setTimeout((()=>{t.scrollBody=function(t){const{location:n,target:o,scrollTarget:r,index:s,indexPrevious:c,limit:{reachedMin:l,reachedMax:a,constrain:u},options:{loop:d}}=t,p="forward"===e.direction?-1:1,g=()=>S;let y=0,m=0,O=n.get(),w=0,b=!1;function I(){let t=0;y=p*e.speed,O+=y,n.add(y),o.set(n),t=O-w,m=Math.sign(t),w=O;const g=r.byDistance(0,!1).index;s.get()!==g&&(c.set(s.get()),s.set(g),i.emit("select"));const I="forward"===e.direction?l(n.get()):a(n.get());if(!d&&I){b=!0;const t=u(n.get());n.set(t),o.set(n),f()}return S}const S={direction:()=>m,duration:()=>-1,velocity:()=>y,settled:()=>b,seek:I,useBaseFriction:g,useBaseDuration:g,useFriction:g,useDuration:g};return S}(t),t.animation.start()}),s),l=!0}function f(){if(r||!l)return;i.emit("autoScroll:stop");const t=i.internalEngine(),{ownerWindow:n}=t;t.scrollBody=c,n.clearTimeout(u),u=0,l=!1}function p(){a&&d(),i.off("settle",p)}function g(){i.on("settle",p)}return{name:"autoScroll",options:o,init:function(l,u){i=l;const{mergeOptions:p,optionsAtMedia:y}=u,m=p(t,n.globalOptions),O=p(m,o);if(e=y(O),i.scrollSnapList().length<=1)return;s=e.startDelay,r=!1,c=i.internalEngine().scrollBody;const{eventStore:w}=i.internalEngine(),b=i.rootNode(),I=e.rootNode&&e.rootNode(b)||b,S=i.containerNode();i.on("pointerDown",f),e.stopOnInteraction||i.on("pointerUp",g),e.stopOnMouseEnter&&(w.add(I,"mouseenter",(()=>{a=!1,f()})),e.stopOnInteraction||w.add(I,"mouseleave",(()=>{a=!0,d()}))),e.stopOnFocusIn&&(w.add(S,"focusin",(()=>{f(),i.scrollTo(i.selectedScrollSnap(),!0)})),e.stopOnInteraction||w.add(S,"focusout",d)),e.playOnInit&&d()},destroy:function(){i.off("pointerDown",f).off("pointerUp",g).off("settle",p),f(),r=!0,l=!1},play:function(t){void 0!==t&&(s=t),a=!0,d()},stop:function(){l&&f()},reset:function(){l&&(f(),g())},isPlaying:function(){return l}}}return n.globalOptions=void 0,n})); |
@@ -67,8 +67,6 @@ const defaultOptions = { | ||
} | ||
if (options.playOnInit) { | ||
emblaApi.on('init', startScroll).on('reInit', startScroll); | ||
} | ||
if (options.playOnInit) startScroll(); | ||
} | ||
function destroy() { | ||
emblaApi.off('init', startScroll).off('reInit', startScroll).off('pointerDown', stopScroll).off('pointerUp', startScrollOnSettle).off('settle', onSettle); | ||
emblaApi.off('pointerDown', stopScroll).off('pointerUp', startScrollOnSettle).off('settle', onSettle); | ||
stopScroll(); | ||
@@ -75,0 +73,0 @@ destroyed = true; |
{ | ||
"name": "embla-carousel-auto-scroll", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"author": "David Jerleke", | ||
@@ -51,3 +51,3 @@ "description": "An auto scroll plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.0.0" | ||
"embla-carousel": "8.0.1" | ||
}, | ||
@@ -54,0 +54,0 @@ "module": "embla-carousel-auto-scroll.esm.js", |
{ | ||
"name": "embla-carousel-auto-scroll", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"author": "David Jerleke", | ||
@@ -62,3 +62,3 @@ "description": "An auto scroll plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.0.0" | ||
"embla-carousel": "8.0.1" | ||
}, | ||
@@ -65,0 +65,0 @@ "exports": { |
@@ -110,2 +110,4 @@ <br /> | ||
<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/sarussss"> | ||
<img src="https://avatars2.githubusercontent.com/u/15656996?s=120&v=4" title="sarussss" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/anzbert"> | ||
@@ -143,4 +145,2 @@ <img src="https://avatars2.githubusercontent.com/u/38823700?s=120&v=4" title="anzbert" width="50" height="50" style="max-width: 100%" /> | ||
<img src="https://avatars2.githubusercontent.com/u/75290989?s=120&v=4" title="fcasibu" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/cundd"> | ||
<img src="https://avatars2.githubusercontent.com/u/743122?s=120&v=4" title="cundd" width="50" height="50" style="max-width: 100%" /> | ||
</a> | ||
@@ -147,0 +147,0 @@ </p> |
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
64098
530