Quellcode durchsuchen

Make sure to cancel the previous scroll before creating new move.

Naotoshi Fujita vor 2 Jahren
Ursprung
Commit
c2f37cb52b

+ 4 - 3
dist/js/splide.js

@@ -1312,7 +1312,7 @@
 
   const Controller = (Splide, Components, options, event) => {
     const { on, emit } = event;
-    const { Move } = Components;
+    const { Move, Scroll } = Components;
     const { getPosition, getLimit, toPosition } = Move;
     const { isEnough, getLength } = Components.Slides;
     const { omitEnd } = options;
@@ -1356,6 +1356,7 @@
         const validIndex = index > -1 && (allowSameIndex || index !== currIndex);
         const canMove = dest === index || Move.canShift(dest > prevIndex);
         if (validIndex && canMove) {
+          Scroll.cancel();
           setIndex(index);
           Move.move(dest, index, prevIndex, callback);
         }
@@ -1369,7 +1370,7 @@
       set({ speed });
     }
     function scroll(destination, duration, snap, callback) {
-      Components.Scroll.scroll(destination, duration, snap, () => {
+      Scroll.scroll(destination, duration, snap, () => {
         const index = loop(Move.toIndex(getPosition()));
         setIndex(omitEnd ? min(index, endIndex) : index);
         callback && callback();
@@ -2318,10 +2319,10 @@
     Layout,
     Clones,
     Move,
+    Scroll,
     Controller,
     Arrows,
     Autoplay,
-    Scroll,
     Drag,
     Keyboard,
     LazyLoad,

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/js/splide.min.js


BIN
dist/js/splide.min.js.gz


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/js/splide.min.js.map


+ 3 - 2
src/js/components/Controller/Controller.ts

@@ -43,7 +43,7 @@ export interface ControllerComponent extends BaseComponent {
  */
 export const Controller: ComponentConstructor<ControllerComponent> = ( Splide, Components, options, event ) => {
   const { on, emit } = event;
-  const { Move } = Components;
+  const { Move, Scroll } = Components;
   const { getPosition, getLimit, toPosition } = Move;
   const { isEnough, getLength } = Components.Slides;
   const { omitEnd } = options;
@@ -140,6 +140,7 @@ export const Controller: ComponentConstructor<ControllerComponent> = ( Splide, C
       const canMove    = dest === index || Move.canShift( dest > prevIndex );
 
       if ( validIndex && canMove ) {
+        Scroll.cancel();
         setIndex( index );
         Move.move( dest, index, prevIndex, callback );
       }
@@ -169,7 +170,7 @@ export const Controller: ComponentConstructor<ControllerComponent> = ( Splide, C
    * @param callback    - Optional. A callback function invoked after scroll ends.
    */
   function scroll( destination: number, duration?: number, snap?: boolean, callback?: AnyFunction ): void {
-    Components.Scroll.scroll( destination, duration, snap, () => {
+    Scroll.scroll( destination, duration, snap, () => {
       const index = loop( Move.toIndex( getPosition() ) );
       setIndex( omitEnd ? min( index, endIndex ) : index );
       callback && callback();

+ 1 - 1
src/js/components/index.ts

@@ -52,10 +52,10 @@ export const COMPONENTS: Record<string, ComponentConstructor> = {
   Layout,
   Clones,
   Move,
+  Scroll,
   Controller,
   Arrows,
   Autoplay,
-  Scroll,
   Drag,
   Keyboard,
   LazyLoad,

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.