itemSize
diff --git a/dist/scroll-snap-slider.js b/dist/scroll-snap-slider.js
index 7a5ba5c..d7e8f19 100644
--- a/dist/scroll-snap-slider.js
+++ b/dist/scroll-snap-slider.js
@@ -268,7 +268,7 @@ class ScrollSnapLoop extends ScrollSnapPlugin {
this.slider.element.style.scrollSnapStop = "";
this.slider.element.style.scrollSnapType = "";
this.slider.attachListeners();
- setTimeout(this.slider.update, 0);
+ requestAnimationFrame(this.slider.update);
}
/**
* Move last slide to the start of the slider.
@@ -452,18 +452,18 @@ class ScrollSnapSlider {
* Updates the computed values
*/
update = () => {
- requestAnimationFrame(() => {
- this.slide = this.roundingMethod(this.element.scrollLeft / this.itemSize);
- this.slideScrollLeft = this.slide * this.itemSize;
- });
+ this.slide = this.roundingMethod(this.element.scrollLeft / this.itemSize);
+ this.slideScrollLeft = this.slide * this.itemSize;
};
/**
* Calculate all necessary things and dispatch an event when sliding stops
*/
onScrollEnd = () => {
- this.scrollTimeoutId = null;
- this.update();
- this.dispatch("slide-stop", this.slide);
+ requestAnimationFrame(() => {
+ this.scrollTimeoutId = null;
+ this.update();
+ this.dispatch("slide-stop", this.slide);
+ });
};
/**
* This will recompute the itemSize
diff --git a/dist/scroll-snap-slider.mjs b/dist/scroll-snap-slider.mjs
index 7032cb0..9d09228 100644
--- a/dist/scroll-snap-slider.mjs
+++ b/dist/scroll-snap-slider.mjs
@@ -266,7 +266,7 @@ class ScrollSnapLoop extends ScrollSnapPlugin {
this.slider.element.style.scrollSnapStop = "";
this.slider.element.style.scrollSnapType = "";
this.slider.attachListeners();
- setTimeout(this.slider.update, 0);
+ requestAnimationFrame(this.slider.update);
}
/**
* Move last slide to the start of the slider.
@@ -450,18 +450,18 @@ class ScrollSnapSlider {
* Updates the computed values
*/
update = () => {
- requestAnimationFrame(() => {
- this.slide = this.roundingMethod(this.element.scrollLeft / this.itemSize);
- this.slideScrollLeft = this.slide * this.itemSize;
- });
+ this.slide = this.roundingMethod(this.element.scrollLeft / this.itemSize);
+ this.slideScrollLeft = this.slide * this.itemSize;
};
/**
* Calculate all necessary things and dispatch an event when sliding stops
*/
onScrollEnd = () => {
- this.scrollTimeoutId = null;
- this.update();
- this.dispatch("slide-stop", this.slide);
+ requestAnimationFrame(() => {
+ this.scrollTimeoutId = null;
+ this.update();
+ this.dispatch("slide-stop", this.slide);
+ });
};
/**
* This will recompute the itemSize
diff --git a/dist/scroll-snap-slider.umd.js b/dist/scroll-snap-slider.umd.js
index 9a4670b..82eded2 100644
--- a/dist/scroll-snap-slider.umd.js
+++ b/dist/scroll-snap-slider.umd.js
@@ -270,7 +270,7 @@
this.slider.element.style.scrollSnapStop = "";
this.slider.element.style.scrollSnapType = "";
this.slider.attachListeners();
- setTimeout(this.slider.update, 0);
+ requestAnimationFrame(this.slider.update);
}
/**
* Move last slide to the start of the slider.
@@ -454,18 +454,18 @@
* Updates the computed values
*/
update = () => {
- requestAnimationFrame(() => {
- this.slide = this.roundingMethod(this.element.scrollLeft / this.itemSize);
- this.slideScrollLeft = this.slide * this.itemSize;
- });
+ this.slide = this.roundingMethod(this.element.scrollLeft / this.itemSize);
+ this.slideScrollLeft = this.slide * this.itemSize;
};
/**
* Calculate all necessary things and dispatch an event when sliding stops
*/
onScrollEnd = () => {
- this.scrollTimeoutId = null;
- this.update();
- this.dispatch("slide-stop", this.slide);
+ requestAnimationFrame(() => {
+ this.scrollTimeoutId = null;
+ this.update();
+ this.dispatch("slide-stop", this.slide);
+ });
};
/**
* This will recompute the itemSize
diff --git a/docs/assets/main.js b/docs/assets/main.js
index 7270cff..3092fea 100644
--- a/docs/assets/main.js
+++ b/docs/assets/main.js
@@ -1,8 +1,8 @@
"use strict";
-"use strict";(()=>{var Pe=Object.create;var ne=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Me=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Fe=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Oe(e))!Re.call(t,i)&&i!==n&&ne(t,i,{get:()=>e[i],enumerable:!(r=Ie(e,i))||r.enumerable});return t};var De=(t,e,n)=>(n=t!=null?Pe(_e(t)):{},Fe(e||!t||!t.__esModule?ne(n,"default",{value:t,enumerable:!0}):n,t));var ae=Me((se,oe)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;iPrivate
debounceUsed to debounce the re-enabling after a user interaction
-Private
Readonly
eventsEvent names that temporarily disable the autoplay behaviour
-Private
intervalInterval ID
-Duration in milliseconds between slide changes
-Reference to the slider this plugin is attached to.
-Duration in milliseconds after human interaction where the slider will not autoplay
-Unique Plugin ID, used as index in ScrollSnapSlider::plugins
.
Private
debounceUsed to debounce the re-enabling after a user interaction
+Private
Readonly
eventsEvent names that temporarily disable the autoplay behaviour
+Private
intervalInterval ID
+Duration in milliseconds between slide changes
+Reference to the slider this plugin is attached to.
+Duration in milliseconds after human interaction where the slider will not autoplay
+Unique Plugin ID, used as index in ScrollSnapSlider::plugins
.
Generated using TypeDoc
Generated using TypeDoc
Classdesc
Plugin that automatically changes slides.
-