Prechádzať zdrojové kódy

Bug Fix: The page index was incorrect in the loop mode (#482).

NaotoshiFujita 3 rokov pred
rodič
commit
da8452a2cb

+ 1 - 1
dist/js/splide-renderer.min.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 3.2.4
+ * Version  : 3.2.5
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */

+ 2 - 2
dist/js/splide.cjs.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 3.2.4
+ * Version  : 3.2.5
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -1392,7 +1392,7 @@ function Controller(Splide2, Components2, options) {
           }
         }
       } else {
-        if (!isLoop && !incremental && dest !== from) {
+        if (!incremental && dest !== from) {
           dest = perMove ? dest : toIndex(toPage(from) + (dest < from ? -1 : 1));
         }
       }

+ 2 - 2
dist/js/splide.esm.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 3.2.4
+ * Version  : 3.2.5
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -1388,7 +1388,7 @@ function Controller(Splide2, Components2, options) {
           }
         }
       } else {
-        if (!isLoop && !incremental && dest !== from) {
+        if (!incremental && dest !== from) {
           dest = perMove ? dest : toIndex(toPage(from) + (dest < from ? -1 : 1));
         }
       }

+ 2 - 2
dist/js/splide.js

@@ -4,7 +4,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
 
 /*!
  * Splide.js
- * Version  : 3.2.4
+ * Version  : 3.2.5
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -1657,7 +1657,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
             }
           }
         } else {
-          if (!isLoop && !incremental && dest !== from) {
+          if (!incremental && dest !== from) {
             dest = perMove ? dest : toIndex(toPage(from) + (dest < from ? -1 : 1));
           }
         }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/js/splide.js.map


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/js/splide.min.js


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


+ 1 - 1
package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "@splidejs/splide",
-  "version": "3.2.4",
+  "version": "3.2.5",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@splidejs/splide",
-  "version": "3.2.4",
+  "version": "3.2.5",
   "description": "Splide is a lightweight, flexible and accessible slider/carousel. No dependencies, no Lighthouse errors.",
   "author": "Naotoshi Fujita",
   "license": "MIT",

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

@@ -243,7 +243,7 @@ export function Controller( Splide: Splide, Components: Components, options: Opt
           }
         }
       } else {
-        if ( ! isLoop && ! incremental && dest !== from ) {
+        if ( ! incremental && dest !== from ) {
           dest = perMove ? dest : toIndex( toPage( from ) + ( dest < from ? -1 : 1 ) );
         }
       }

+ 10 - 4
src/js/components/Controller/test/loop.test.ts

@@ -18,12 +18,18 @@ describe( 'Controller#go()', () => {
     expect( splide.index ).toBe( 0 );
   } );
 
-  test( 'can loop the slider, using the end index.', () => {
-    // The end index is 1.
-    const splide = init( { rewind: true, perPage: 3, speed: 0 }, { length: 4 } );
+  test( 'can loop the slider, using the index of the last page.', () => {
+    // The length is 10 and the last page only contains the slide 9.
+    const splide = init( { type: 'loop', perPage: 3, speed: 0 } );
 
     splide.go( '<' );
-    expect( splide.index ).toBe( 1 );
+    expect( splide.index ).toBe( 9 ); // 9, 0, 1
+
+    splide.go( '<' );
+    expect( splide.index ).toBe( 6 ); // 6, 7, 8
+
+    splide.go( '>' );
+    expect( splide.index ).toBe( 7 ); // 7, 8, 9
 
     splide.go( '>' );
     expect( splide.index ).toBe( 0 );

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

@@ -19,14 +19,14 @@ $settings = get_settings();
   <script>
     document.addEventListener( 'DOMContentLoaded', function () {
       var splide = new Splide( '#splide01', {
-        type   : 'slide',
-        perPage: 3,
-        perMove: 2,
+        type   : 'loop',
+        perPage: 5,
+        // perMove: 2,
         rewind: true,
-        padding: {
-          right: 0,
-          left: 40,
-        },
+        // padding: {
+        //   right: 0,
+        //   left: 40,
+        // },
         noDrag: 'button',
       } );
 
@@ -58,7 +58,7 @@ $settings = get_settings();
 </head>
 <body>
 
-<?php render(); ?>
+<?php render( 'splide01', 12, true ); ?>
 
 <pre></pre>
 

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov