فهرست منبع

Add the `updateOnDragged` option.

Naotoshi Fujita 2 سال پیش
والد
کامیت
17251a9308
7فایلهای تغییر یافته به همراه18 افزوده شده و 5 حذف شده
  1. 6 3
      dist/js/splide.js
  2. 0 0
      dist/js/splide.min.js
  3. BIN
      dist/js/splide.min.js.gz
  4. 0 0
      dist/js/splide.min.js.map
  5. 3 1
      src/js/components/Drag/Drag.ts
  6. 3 1
      src/js/test/php/examples/sync.php
  7. 6 0
      src/js/types/options.ts

+ 6 - 3
dist/js/splide.js

@@ -1800,7 +1800,9 @@
           Move.translate(basePosition + constrain(diffCoord(e)));
           Move.translate(basePosition + constrain(diffCoord(e)));
           const expired = diffTime(e) > LOG_INTERVAL;
           const expired = diffTime(e) > LOG_INTERVAL;
           const hasExceeded = exceeded !== (exceeded = exceededLimit());
           const hasExceeded = exceeded !== (exceeded = exceededLimit());
-          expired || hasExceeded && save(e);
+          if (expired || hasExceeded) {
+            save(e);
+          }
           clickPrevented = true;
           clickPrevented = true;
           emit(EVENT_DRAGGING);
           emit(EVENT_DRAGGING);
           prevent(e);
           prevent(e);
@@ -1821,7 +1823,6 @@
       }
       }
       binder.destroy();
       binder.destroy();
       dragging = false;
       dragging = false;
-      exceeded = false;
     }
     }
     function onClick(e) {
     function onClick(e) {
       if (!disabled && clickPrevented) {
       if (!disabled && clickPrevented) {
@@ -1834,12 +1835,14 @@
       basePosition = getPosition();
       basePosition = getPosition();
     }
     }
     function move(e) {
     function move(e) {
+      const { updateOnDragged = true } = options;
       const velocity = computeVelocity(e);
       const velocity = computeVelocity(e);
       const destination = computeDestination(velocity);
       const destination = computeDestination(velocity);
       const rewind = options.rewind && options.rewindByDrag;
       const rewind = options.rewind && options.rewindByDrag;
+      const scroll = updateOnDragged ? Controller.scroll : Scroll.scroll;
       reduce(false);
       reduce(false);
       if (isFree) {
       if (isFree) {
-        Controller.scroll(destination, void 0, options.snap);
+        scroll(destination, void 0, options.snap);
       } else if (Splide.is(FADE)) {
       } else if (Splide.is(FADE)) {
         Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+");
         Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+");
       } else if (Splide.is(SLIDE) && exceeded && rewind) {
       } else if (Splide.is(SLIDE) && exceeded && rewind) {

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/js/splide.min.js


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


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/js/splide.min.js.map


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

@@ -228,14 +228,16 @@ export const Drag: ComponentConstructor<DragComponent> = ( Splide, Components, o
    * @param e - A TouchEvent or MouseEvent object.
    * @param e - A TouchEvent or MouseEvent object.
    */
    */
   function move( e: TouchEvent | MouseEvent ): void {
   function move( e: TouchEvent | MouseEvent ): void {
+    const { updateOnDragged = true } = options;
     const velocity    = computeVelocity( e );
     const velocity    = computeVelocity( e );
     const destination = computeDestination( velocity );
     const destination = computeDestination( velocity );
     const rewind      = options.rewind && options.rewindByDrag;
     const rewind      = options.rewind && options.rewindByDrag;
+    const scroll      = updateOnDragged ? Controller.scroll : Scroll.scroll;
 
 
     reduce( false );
     reduce( false );
 
 
     if ( isFree ) {
     if ( isFree ) {
-      Controller.scroll( destination, undefined, options.snap );
+      scroll( destination, undefined, options.snap );
     } else if ( Splide.is( FADE ) ) {
     } else if ( Splide.is( FADE ) ) {
       Controller.go( orient( sign( velocity ) ) < 0 ? ( rewind ? '<' : '-' ) : ( rewind ? '>' : '+' ) );
       Controller.go( orient( sign( velocity ) ) < 0 ? ( rewind ? '<' : '-' ) : ( rewind ? '>' : '+' ) );
     } else if ( Splide.is( SLIDE ) && exceeded && rewind ) {
     } else if ( Splide.is( SLIDE ) && exceeded && rewind ) {

+ 3 - 1
src/js/test/php/examples/sync.php

@@ -32,7 +32,7 @@ $settings = get_settings();
 	    } );
 	    } );
 
 
 	    var splide02 = new Splide( '#splide02', {
 	    var splide02 = new Splide( '#splide02', {
-		    // type             : 'loop',
+		    type            : 'loop',
 		    width           : 600,
 		    width           : 600,
 		    fixedWidth      : 100,
 		    fixedWidth      : 100,
 		    fixedHeight     : 56,
 		    fixedHeight     : 56,
@@ -42,6 +42,8 @@ $settings = get_settings();
 		    pagination      : false,
 		    pagination      : false,
 		    rewind          : true,
 		    rewind          : true,
 		    keyboard        : false,
 		    keyboard        : false,
+        drag            : 'free',
+        updateOnDragged : false,
 		    dragMinThreshold: {
 		    dragMinThreshold: {
 			    mouse: 10,
 			    mouse: 10,
 			    touch: 10,
 			    touch: 10,

+ 6 - 0
src/js/types/options.ts

@@ -399,6 +399,12 @@ export interface ResponsiveOptions {
    */
    */
   flickMaxPages?: number;
   flickMaxPages?: number;
 
 
+  /**
+   * If `drag` is `'free'`, determines whether to activate the closest slide after drag or not.
+   * The default value is `true`.
+   */
+  updateOnDragged?: boolean;
+
   /**
   /**
    * Enables navigation by the mouse wheel.
    * Enables navigation by the mouse wheel.
    * You'll need to set `waitForTransition` to `ture` or provide the `wheelSleep` duration to avoid quick change.
    * You'll need to set `waitForTransition` to `ture` or provide the `wheelSleep` duration to avoid quick change.

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است