Преглед изворни кода

Bug Fix: Filters invalid offset values.

NaotoshiFujita пре 3 година
родитељ
комит
a5ad9714c5

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
dist/js/splide-renderer.min.js


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

@@ -2544,7 +2544,7 @@ class SplideRenderer {
       values.push(this.buildCssValue(orient(-50), "%"));
       values.push(this.buildCssValue(orient(-50), "%"));
       values.push(...this.cssOffsetCenter(options));
       values.push(...this.cssOffsetCenter(options));
     }
     }
-    return values.map((value) => `translate${resolve("X")}(${value})`).join(" ");
+    return values.filter(Boolean).map((value) => `translate${resolve("X")}(${value})`).join(" ");
   }
   }
   cssOffsetClones(options) {
   cssOffsetClones(options) {
     const { resolve, orient } = this.Direction;
     const { resolve, orient } = this.Direction;
@@ -2643,9 +2643,6 @@ class SplideRenderer {
   isFixedWidth(options) {
   isFixedWidth(options) {
     return !!options[this.Direction.resolve("fixedWidth")];
     return !!options[this.Direction.resolve("fixedWidth")];
   }
   }
-  isAutoWidth(options) {
-    return !!options[this.Direction.resolve("autoWidth")];
-  }
   isLoop() {
   isLoop() {
     return this.options.type === LOOP;
     return this.options.type === LOOP;
   }
   }

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

@@ -2540,7 +2540,7 @@ class SplideRenderer {
       values.push(this.buildCssValue(orient(-50), "%"));
       values.push(this.buildCssValue(orient(-50), "%"));
       values.push(...this.cssOffsetCenter(options));
       values.push(...this.cssOffsetCenter(options));
     }
     }
-    return values.map((value) => `translate${resolve("X")}(${value})`).join(" ");
+    return values.filter(Boolean).map((value) => `translate${resolve("X")}(${value})`).join(" ");
   }
   }
   cssOffsetClones(options) {
   cssOffsetClones(options) {
     const { resolve, orient } = this.Direction;
     const { resolve, orient } = this.Direction;
@@ -2639,9 +2639,6 @@ class SplideRenderer {
   isFixedWidth(options) {
   isFixedWidth(options) {
     return !!options[this.Direction.resolve("fixedWidth")];
     return !!options[this.Direction.resolve("fixedWidth")];
   }
   }
-  isAutoWidth(options) {
-    return !!options[this.Direction.resolve("autoWidth")];
-  }
   isLoop() {
   isLoop() {
     return this.options.type === LOOP;
     return this.options.type === LOOP;
   }
   }

+ 0 - 6
dist/types/renderer/SplideRenderer/SplideRenderer.d.ts

@@ -208,12 +208,6 @@ export declare class SplideRenderer {
      * @return `true` if the slide width is fixed, or otherwise `false`.
      * @return `true` if the slide width is fixed, or otherwise `false`.
      */
      */
     private isFixedWidth;
     private isFixedWidth;
-    /**
-     * Checks if the `autoWidth` is active or not.
-     *
-     * @return `true` if the `autoWidth` is active, or otherwise `false`.
-     */
-    private isAutoWidth;
     /**
     /**
      * Checks if the slider type is loop or not.
      * Checks if the slider type is loop or not.
      *
      *

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
dist/types/renderer/SplideRenderer/SplideRenderer.d.ts.map


+ 5 - 11
src/js/renderer/SplideRenderer/SplideRenderer.ts

@@ -228,7 +228,10 @@ export class SplideRenderer {
       values.push( ...this.cssOffsetCenter( options ) );
       values.push( ...this.cssOffsetCenter( options ) );
     }
     }
 
 
-    return values.map( value => `translate${ resolve( 'X' ) }(${ value })` ).join( ' ' );
+    return values
+      .filter( Boolean )
+      .map( value => `translate${ resolve( 'X' ) }(${ value })` )
+      .join( ' ' );
   }
   }
 
 
   /**
   /**
@@ -472,15 +475,6 @@ export class SplideRenderer {
     return !! options[ this.Direction.resolve( 'fixedWidth' ) ];
     return !! options[ this.Direction.resolve( 'fixedWidth' ) ];
   }
   }
 
 
-  /**
-   * Checks if the `autoWidth` is active or not.
-   *
-   * @return `true` if the `autoWidth` is active, or otherwise `false`.
-   */
-  private isAutoWidth( options: Options ): boolean {
-    return !! options[ this.Direction.resolve( 'autoWidth' ) ];
-  }
-
   /**
   /**
    * Checks if the slider type is loop or not.
    * Checks if the slider type is loop or not.
    *
    *
@@ -496,7 +490,7 @@ export class SplideRenderer {
    * @return `true` if the slide should be centered, or otherwise `false`.
    * @return `true` if the slide should be centered, or otherwise `false`.
    */
    */
   private isCenter( options: Options ): boolean {
   private isCenter( options: Options ): boolean {
-    if( options.focus === 'center'  ) {
+    if( options.focus === 'center' ) {
       if ( this.isLoop() ) {
       if ( this.isLoop() ) {
         return true;
         return true;
       }
       }

+ 5 - 4
src/js/test/php/examples/renderer.php

@@ -20,7 +20,7 @@ $settings = get_settings();
   <script>
   <script>
     document.addEventListener( 'DOMContentLoaded', function () {
     document.addEventListener( 'DOMContentLoaded', function () {
       const options = {
       const options = {
-        type: 'loop',
+        // type: 'loop',
         // padding: '1rem',
         // padding: '1rem',
         perPage: 3,
         perPage: 3,
         gap: 100,
         gap: 100,
@@ -29,6 +29,7 @@ $settings = get_settings();
         // fixedHeight: '20rem',
         // fixedHeight: '20rem',
         // direction: 'ttb',
         // direction: 'ttb',
         cover: true,
         cover: true,
+        trimSpace: false,
         heightRatio: 0.4,
         heightRatio: 0.4,
         breakpoints: {
         breakpoints: {
           1000: {
           1000: {
@@ -100,9 +101,9 @@ $settings = get_settings();
       wrapper.innerHTML = renderer.html();
       wrapper.innerHTML = renderer.html();
 
 
       setTimeout( () => {
       setTimeout( () => {
-        var splide = new Splide( wrapper.firstElementChild, options );
-        SplideRenderer.clean( splide );
-        splide.mount();
+        // var splide = new Splide( wrapper.firstElementChild, options );
+        // SplideRenderer.clean( splide );
+        // splide.mount();
       }, 2000 );
       }, 2000 );
     } );
     } );
   </script>
   </script>

Неке датотеке нису приказане због велике количине промена