ソースを参照

Add the `updateOnDragged` option.

Naotoshi Fujita 2 年 前
コミット
17251a9308

+ 6 - 3
dist/js/splide.js

@@ -1800,7 +1800,9 @@
           Move.translate(basePosition + constrain(diffCoord(e)));
           const expired = diffTime(e) > LOG_INTERVAL;
           const hasExceeded = exceeded !== (exceeded = exceededLimit());
-          expired || hasExceeded && save(e);
+          if (expired || hasExceeded) {
+            save(e);
+          }
           clickPrevented = true;
           emit(EVENT_DRAGGING);
           prevent(e);
@@ -1821,7 +1823,6 @@
       }
       binder.destroy();
       dragging = false;
-      exceeded = false;
     }
     function onClick(e) {
       if (!disabled && clickPrevented) {
@@ -1834,12 +1835,14 @@
       basePosition = getPosition();
     }
     function move(e) {
+      const { updateOnDragged = true } = options;
       const velocity = computeVelocity(e);
       const destination = computeDestination(velocity);
       const rewind = options.rewind && options.rewindByDrag;
+      const scroll = updateOnDragged ? Controller.scroll : Scroll.scroll;
       reduce(false);
       if (isFree) {
-        Controller.scroll(destination, void 0, options.snap);
+        scroll(destination, void 0, options.snap);
       } else if (Splide.is(FADE)) {
         Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : 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.
    */
   function move( e: TouchEvent | MouseEvent ): void {
+    const { updateOnDragged = true } = options;
     const velocity    = computeVelocity( e );
     const destination = computeDestination( velocity );
     const rewind      = options.rewind && options.rewindByDrag;
+    const scroll      = updateOnDragged ? Controller.scroll : Scroll.scroll;
 
     reduce( false );
 
     if ( isFree ) {
-      Controller.scroll( destination, undefined, options.snap );
+      scroll( destination, undefined, options.snap );
     } else if ( Splide.is( FADE ) ) {
       Controller.go( orient( sign( velocity ) ) < 0 ? ( rewind ? '<' : '-' ) : ( 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', {
-		    // type             : 'loop',
+		    type            : 'loop',
 		    width           : 600,
 		    fixedWidth      : 100,
 		    fixedHeight     : 56,
@@ -42,6 +42,8 @@ $settings = get_settings();
 		    pagination      : false,
 		    rewind          : true,
 		    keyboard        : false,
+        drag            : 'free',
+        updateOnDragged : false,
 		    dragMinThreshold: {
 			    mouse: 10,
 			    touch: 10,

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

@@ -399,6 +399,12 @@ export interface ResponsiveOptions {
    */
   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.
    * You'll need to set `waitForTransition` to `ture` or provide the `wheelSleep` duration to avoid quick change.

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません