Pārlūkot izejas kodu

Improve performance.

NaotoshiFujita 3 gadi atpakaļ
vecāks
revīzija
141b190bb1

+ 6 - 4
dist/js/splide.cjs.js

@@ -1193,7 +1193,7 @@ function Move(Splide2, Components2, options) {
   }
   function reposition() {
     Components2.Scroll.cancel();
-    cancel();
+    cancel(false);
     jump(Splide2.index);
   }
   function move(dest, index, prev, callback) {
@@ -1234,10 +1234,12 @@ function Move(Splide2, Components2, options) {
     }
     return position;
   }
-  function cancel() {
+  function cancel(settle) {
     waiting = false;
     Components2.Transition.cancel();
-    translate(getPosition());
+    if (settle) {
+      translate(getPosition());
+    }
   }
   function toIndex(position) {
     const Slides = Components2.Slides.get();
@@ -1756,7 +1758,7 @@ function Drag(Splide2, Components2, options) {
           clickPrevented = false;
           bind(target, POINTER_MOVE_EVENTS, onPointerMove);
           bind(target, POINTER_UP_EVENTS, onPointerUp);
-          Move.cancel();
+          Move.cancel(true);
           Scroll.cancel();
           save(e);
         } else {

+ 6 - 4
dist/js/splide.esm.js

@@ -1189,7 +1189,7 @@ function Move(Splide2, Components2, options) {
   }
   function reposition() {
     Components2.Scroll.cancel();
-    cancel();
+    cancel(false);
     jump(Splide2.index);
   }
   function move(dest, index, prev, callback) {
@@ -1230,10 +1230,12 @@ function Move(Splide2, Components2, options) {
     }
     return position;
   }
-  function cancel() {
+  function cancel(settle) {
     waiting = false;
     Components2.Transition.cancel();
-    translate(getPosition());
+    if (settle) {
+      translate(getPosition());
+    }
   }
   function toIndex(position) {
     const Slides = Components2.Slides.get();
@@ -1752,7 +1754,7 @@ function Drag(Splide2, Components2, options) {
           clickPrevented = false;
           bind(target, POINTER_MOVE_EVENTS, onPointerMove);
           bind(target, POINTER_UP_EVENTS, onPointerUp);
-          Move.cancel();
+          Move.cancel(true);
           Scroll.cancel();
           save(e);
         } else {

+ 7 - 4
dist/js/splide.js

@@ -1418,7 +1418,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
 
     function reposition() {
       Components2.Scroll.cancel();
-      cancel();
+      cancel(false);
       jump(Splide2.index);
     }
 
@@ -1467,10 +1467,13 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       return position;
     }
 
-    function cancel() {
+    function cancel(settle) {
       waiting = false;
       Components2.Transition.cancel();
-      translate(getPosition());
+
+      if (settle) {
+        translate(getPosition());
+      }
     }
 
     function toIndex(position) {
@@ -2122,7 +2125,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
             clickPrevented = false;
             bind(target, POINTER_MOVE_EVENTS, onPointerMove);
             bind(target, POINTER_UP_EVENTS, onPointerUp);
-            Move.cancel();
+            Move.cancel(true);
             Scroll.cancel();
             save(e);
           } else {

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
dist/js/splide.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
dist/js/splide.min.js


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


+ 1 - 1
dist/types/components/Move/Move.d.ts

@@ -9,7 +9,7 @@ export interface MoveComponent extends BaseComponent {
     move(dest: number, index: number, prev: number, callback?: AnyFunction): void;
     jump(index: number): void;
     translate(position: number): void;
-    cancel(): void;
+    cancel(settle?: boolean): void;
     toIndex(position: number): number;
     toPosition(index: number, trimming?: boolean): number;
     getPosition(): number;

+ 1 - 1
dist/types/components/Move/Move.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"Move.d.ts","sourceRoot":"","sources":["Move.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI9E;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,IAAI,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAI,IAAI,CAAC;IAChF,IA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M,CAAC;IACpC,UAAU,CAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACxD,WAAW,IAAI,MAAM,CAAC;IACtB,QAAQ,CAAE,GAAG,EAAE,OAAO,GAAI,MAAM,CAAC;IACjC,MAAM,IAAI,OAAO,CAAC;IAClB,aAAa,CAAE,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC;CACxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,aAAa,CAkP9F"}

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

@@ -130,7 +130,7 @@ export function Drag( Splide: Splide, Components: Components, options: Options )
 
           bind( target, POINTER_MOVE_EVENTS, onPointerMove );
           bind( target, POINTER_UP_EVENTS, onPointerUp );
-          Move.cancel();
+          Move.cancel( true );
           Scroll.cancel();
           save( e );
         } else {

+ 9 - 4
src/js/components/Move/Move.ts

@@ -24,7 +24,7 @@ export interface MoveComponent extends BaseComponent {
   move( dest: number, index: number, prev: number, callback?: AnyFunction ): void;
   jump( index: number ): void;
   translate( position: number ): void;
-  cancel(): void;
+  cancel( settle?: boolean ): void;
   toIndex( position: number ): number;
   toPosition( index: number, trimming?: boolean ): number;
   getPosition(): number;
@@ -70,7 +70,7 @@ export function Move( Splide: Splide, Components: Components, options: Options )
    */
   function reposition(): void {
     Components.Scroll.cancel();
-    cancel();
+    cancel( false );
     jump( Splide.index );
   }
 
@@ -150,11 +150,16 @@ export function Move( Splide: Splide, Components: Components, options: Options )
 
   /**
    * Cancels transition.
+   *
+   * @param settle - Determines whether to settle the position or not.
    */
-  function cancel(): void {
+  function cancel( settle?: boolean ): void {
     waiting = false;
     Components.Transition.cancel();
-    translate( getPosition() );
+
+    if ( settle ) {
+      translate( getPosition() );
+    }
   }
 
   /**

+ 8 - 2
src/js/test/php/examples/default.php

@@ -20,7 +20,7 @@ $settings = get_settings();
     document.addEventListener( 'DOMContentLoaded', function () {
       var splide = new Splide( '#splide01', {
         // type   : 'loop',
-        perPage: 1,
+        perPage: 3,
         gap    : '1.5rem',
         height : 400,
         start  : 2,
@@ -28,10 +28,16 @@ $settings = get_settings();
         // cover  : true,
         // speed: 1000,
         // padding: '20%',
+        waitForTransition: false,
         classes: {
           arrows: 'splide__arrows splide__test',
           clone : 'splide__clone splide__test',
-        }
+        },
+        breakpoints: {
+          640: {
+            perPage: 2,
+          }
+        },
       } );
 
       splide.on( 'moved', () => {

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels