Browse Source

Refactoring.

NaotoshiFujita 3 years ago
parent
commit
5da1e2732f

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

@@ -3047,20 +3047,17 @@ function Controller(Splide, Components, options) {
   /**
    * Moves the slider by the control pattern.
    *
-   * @todo
-   *
    * @see `Splide#go()`
    *
-   * @param control        - A control pattern.
-   * @param allowSameIndex - Optional. Determines whether to allow to go to the current index or not.
+   * @param control - A control pattern.
    */
 
 
-  function go(control, allowSameIndex) {
+  function go(control) {
     var dest = parse(control);
     var index = loop(dest);
 
-    if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) {
+    if (index > -1 && !Move.isBusy()) {
       setIndex(index);
       Move.move(dest, index, prevIndex);
     }
@@ -4138,7 +4135,7 @@ function Drag(Splide, Components, options) {
       if (isFree) {
         Scroll.scroll(destination);
       } else {
-        go(computeIndex(destination), true);
+        go(computeIndex(destination));
       }
     }
 

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

@@ -3042,20 +3042,17 @@ function Controller(Splide, Components, options) {
   /**
    * Moves the slider by the control pattern.
    *
-   * @todo
-   *
    * @see `Splide#go()`
    *
-   * @param control        - A control pattern.
-   * @param allowSameIndex - Optional. Determines whether to allow to go to the current index or not.
+   * @param control - A control pattern.
    */
 
 
-  function go(control, allowSameIndex) {
+  function go(control) {
     var dest = parse(control);
     var index = loop(dest);
 
-    if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) {
+    if (index > -1 && !Move.isBusy()) {
       setIndex(index);
       Move.move(dest, index, prevIndex);
     }
@@ -4133,7 +4130,7 @@ function Drag(Splide, Components, options) {
       if (isFree) {
         Scroll.scroll(destination);
       } else {
-        go(computeIndex(destination), true);
+        go(computeIndex(destination));
       }
     }
 

+ 4 - 2
dist/js/splide.js

@@ -3046,8 +3046,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     /**
      * Moves the slider by the control pattern.
      *
-     * @todo
-     *
      * @see `Splide#go()`
      *
      * @param control        - A control pattern.
@@ -3998,6 +3996,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
      */
 
     var isMouse;
+    /**
+     * The target element to attach listeners.
+     */
+
     var target;
     /**
      * Indicates whether the slider exceeds borders or not.

File diff suppressed because it is too large
+ 0 - 0
dist/js/splide.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/js/splide.min.js


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


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

@@ -6,7 +6,7 @@ import { BaseComponent, Components, Options } from '../../types';
  * @since 3.0.0
  */
 export interface ControllerComponent extends BaseComponent {
-    go(control: number | string, allowSameIndex?: boolean): void;
+    go(control: number | string): void;
     getNext(destination?: boolean): number;
     getPrev(destination?: boolean): number;
     getEnd(): number;

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

@@ -1 +1 @@
-{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["Controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAIjE;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,EAAE,CAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAI,IAAI,CAAC;IAC/D,OAAO,CAAE,WAAW,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACzC,OAAO,CAAE,WAAW,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACzC,MAAM,IAAI,MAAM,CAAC;IACjB,QAAQ,CAAE,KAAK,EAAE,MAAM,GAAI,IAAI,CAAC;IAChC,QAAQ,CAAE,IAAI,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACnC,OAAO,CAAE,IAAI,EAAE,MAAM,GAAI,MAAM,CAAC;IAChC,MAAM,CAAE,KAAK,EAAE,MAAM,GAAI,MAAM,CAAC;IAChC,QAAQ,IAAI,OAAO,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,mBAAmB,CAiS1G"}
+{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["Controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAIjE;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,EAAE,CAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAI,IAAI,CAAC;IACrC,OAAO,CAAE,WAAW,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACzC,OAAO,CAAE,WAAW,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACzC,MAAM,IAAI,MAAM,CAAC;IACjB,QAAQ,CAAE,KAAK,EAAE,MAAM,GAAI,IAAI,CAAC;IAChC,QAAQ,CAAE,IAAI,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACnC,OAAO,CAAE,IAAI,EAAE,MAAM,GAAI,MAAM,CAAC;IAChC,MAAM,CAAE,KAAK,EAAE,MAAM,GAAI,MAAM,CAAC;IAChC,QAAQ,IAAI,OAAO,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,mBAAmB,CA8R1G"}

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

@@ -91,8 +91,6 @@ export function Controller( Splide: Splide, Components: Components, options: Opt
   /**
    * Moves the slider by the control pattern.
    *
-   * @todo
-   *
    * @see `Splide#go()`
    *
    * @param control        - A control pattern.

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

@@ -78,6 +78,9 @@ export function Drag( Splide: Splide, Components: Components, options: Options )
    */
   let isMouse: boolean;
 
+  /**
+   * The target element to attach listeners.
+   */
   let target: Window | HTMLElement;
 
   /**

+ 2 - 2
src/js/components/Sync/test/sync.test.ts

@@ -72,10 +72,10 @@ describe( 'Sync#sync()', () => {
     primary.on( EVENT_MOVE, callback );
 
     primary.go( 1 );
-    expect( callback ).toBeCalledTimes( 1 );
+    expect( callback ).toHaveBeenCalledTimes( 1 );
 
     secondary.go( 2 );
-    expect( callback ).toBeCalledTimes( 2 );
+    expect( callback ).toHaveBeenCalledTimes( 2 );
   } );
 } );
 

+ 4 - 0
src/js/test/php/examples/default.php

@@ -24,6 +24,10 @@ $settings = get_settings();
         drag   : 'free',
       } );
 
+      splide.on( 'moved', () => {
+        console.log( 'moved' );
+      } );
+
       splide.mount();
     } );
   </script>

Some files were not shown because too many files changed in this diff