embla-carousel-auto-scroll
Advanced tools
Comparing version 8.1.6 to 8.1.7
@@ -113,2 +113,4 @@ 'use strict'; | ||
location, | ||
previousLocation, | ||
offsetLocation, | ||
target, | ||
@@ -134,7 +136,9 @@ scrollTarget, | ||
let hasSettled = false; | ||
function seek() { | ||
function seek(timeStep) { | ||
const fixedDeltaTimeSeconds = timeStep / 1000; | ||
let directionDiff = 0; | ||
bodyVelocity = directionSign * options.speed; | ||
previousLocation.set(location); | ||
bodyVelocity = directionSign * options.speed * 55; | ||
rawLocation += bodyVelocity; | ||
location.add(bodyVelocity); | ||
location.add(bodyVelocity * fixedDeltaTimeSeconds); | ||
target.set(location); | ||
@@ -150,3 +154,3 @@ directionDiff = rawLocation - rawLocationPrevious; | ||
} | ||
const reachedEnd = options.direction === 'forward' ? reachedMin(location.get()) : reachedMax(location.get()); | ||
const reachedEnd = options.direction === 'forward' ? reachedMin(offsetLocation.get()) : reachedMax(offsetLocation.get()); | ||
if (!loop && reachedEnd) { | ||
@@ -153,0 +157,0 @@ hasSettled = true; |
{ | ||
"name": "embla-carousel-auto-scroll", | ||
"version": "8.1.6", | ||
"version": "8.1.7", | ||
"author": "David Jerleke", | ||
@@ -51,3 +51,3 @@ "description": "An auto scroll plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.1.6" | ||
"embla-carousel": "8.1.7" | ||
}, | ||
@@ -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(),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})); | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(t="undefined"!=typeof globalThis?globalThis:t||self).EmblaCarouselAutoScroll=o()}(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 o(n={}){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:o}=t;u=o.setTimeout((()=>{t.scrollBody=function(t){const{location:o,previousLocation:n,offsetLocation:r,target:s,scrollTarget:c,index:l,indexPrevious:a,limit:{reachedMin:u,reachedMax:d,constrain:p},options:{loop:g}}=t,y="forward"===e.direction?-1:1,m=()=>h;let O=0,w=0,b=o.get(),v=0,I=!1;function S(t){const m=t/1e3;let S=0;n.set(o),O=y*e.speed*55,b+=O,o.add(O*m),s.set(o),S=b-v,w=Math.sign(S),v=b;const D=c.byDistance(0,!1).index;l.get()!==D&&(a.set(l.get()),l.set(D),i.emit("select"));const E="forward"===e.direction?u(r.get()):d(r.get());if(!g&&E){I=!0;const t=p(o.get());o.set(t),s.set(o),f()}return h}const h={direction:()=>w,duration:()=>-1,velocity:()=>O,settled:()=>I,seek:S,useBaseFriction:m,useBaseDuration:m,useFriction:m,useDuration:m};return h}(t),t.animation.start()}),s),l=!0}function f(){if(r||!l)return;i.emit("autoScroll:stop");const t=i.internalEngine(),{ownerWindow:o}=t;t.scrollBody=c,o.clearTimeout(u),u=0,l=!1}function p(){a&&d(),i.off("settle",p)}function g(){i.on("settle",p)}return{name:"autoScroll",options:n,init:function(l,u){i=l;const{mergeOptions:p,optionsAtMedia:y}=u,m=p(t,o.globalOptions),O=p(m,n);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(),v=e.rootNode&&e.rootNode(b)||b,I=i.containerNode();i.on("pointerDown",f),e.stopOnInteraction||i.on("pointerUp",g),e.stopOnMouseEnter&&(w.add(v,"mouseenter",(()=>{a=!1,f()})),e.stopOnInteraction||w.add(v,"mouseleave",(()=>{a=!0,d()}))),e.stopOnFocusIn&&(w.add(I,"focusin",(()=>{f(),i.scrollTo(i.selectedScrollSnap(),!0)})),e.stopOnInteraction||w.add(I,"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 o.globalOptions=void 0,o})); |
@@ -111,2 +111,4 @@ const defaultOptions = { | ||
location, | ||
previousLocation, | ||
offsetLocation, | ||
target, | ||
@@ -132,7 +134,9 @@ scrollTarget, | ||
let hasSettled = false; | ||
function seek() { | ||
function seek(timeStep) { | ||
const fixedDeltaTimeSeconds = timeStep / 1000; | ||
let directionDiff = 0; | ||
bodyVelocity = directionSign * options.speed; | ||
previousLocation.set(location); | ||
bodyVelocity = directionSign * options.speed * 55; | ||
rawLocation += bodyVelocity; | ||
location.add(bodyVelocity); | ||
location.add(bodyVelocity * fixedDeltaTimeSeconds); | ||
target.set(location); | ||
@@ -148,3 +152,3 @@ directionDiff = rawLocation - rawLocationPrevious; | ||
} | ||
const reachedEnd = options.direction === 'forward' ? reachedMin(location.get()) : reachedMax(location.get()); | ||
const reachedEnd = options.direction === 'forward' ? reachedMin(offsetLocation.get()) : reachedMax(offsetLocation.get()); | ||
if (!loop && reachedEnd) { | ||
@@ -151,0 +155,0 @@ hasSettled = true; |
{ | ||
"name": "embla-carousel-auto-scroll", | ||
"version": "8.1.6", | ||
"version": "8.1.7", | ||
"author": "David Jerleke", | ||
@@ -51,3 +51,3 @@ "description": "An auto scroll plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.1.6" | ||
"embla-carousel": "8.1.7" | ||
}, | ||
@@ -54,0 +54,0 @@ "module": "embla-carousel-auto-scroll.esm.js", |
{ | ||
"name": "embla-carousel-auto-scroll", | ||
"version": "8.1.6", | ||
"version": "8.1.7", | ||
"author": "David Jerleke", | ||
@@ -62,3 +62,3 @@ "description": "An auto scroll plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "8.1.6" | ||
"embla-carousel": "8.1.7" | ||
}, | ||
@@ -65,0 +65,0 @@ "exports": { |
@@ -102,2 +102,4 @@ <br /> | ||
<img src="https://avatars2.githubusercontent.com/u/91487491?s=120&v=4" title="hamidrezahanafi" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/negezor"> | ||
<img src="https://avatars2.githubusercontent.com/u/9392723?s=120&v=4" title="negezor" width="50" height="50" style="max-width: 100%" /> | ||
</a><a href="https://github.com/th-km"> | ||
@@ -104,0 +106,0 @@ <img src="https://avatars2.githubusercontent.com/u/35410212?s=120&v=4" title="th-km" 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
65885
532
216