Sfoglia il codice sorgente

Revert "Always resize the carousel on update and refresh."

This reverts commit b5d1e3b632e8d3efbea8ea3045899ca3052a553e.
Naotoshi Fujita 2 anni fa
parent
commit
a80902dc1a

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

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 4.0.21
+ * Version  : 4.0.20
  * License  : MIT
  * Copyright: 2022 Naotoshi Fujita
  */

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

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 4.0.21
+ * Version  : 4.0.20
  * License  : MIT
  * Copyright: 2022 Naotoshi Fujita
  */
@@ -1212,17 +1212,18 @@ function Layout(Splide2, Components2, options) {
   }
 
   function init() {
+    rootRect = null;
     vertical = options.direction === TTB;
     style(root, "maxWidth", unit(options.width));
     style(track, resolve("paddingLeft"), cssPadding(false));
     style(track, resolve("paddingRight"), cssPadding(true));
-    resize(true);
+    resize();
   }
 
-  function resize(force) {
+  function resize() {
     var newRect = rect(root);
 
-    if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
+    if (!rootRect || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
       style(track, "height", cssTrackHeight());
       styleSlides(resolve("marginRight"), unit(options.gap));
       styleSlides("width", cssSlideWidth());
@@ -2830,7 +2831,6 @@ function Live(Splide2, Components2, options) {
       interval.start();
     } else {
       remove(sr);
-      interval.cancel();
     }
   }
 

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

@@ -4,7 +4,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
 
 /*!
  * Splide.js
- * Version  : 4.0.21
+ * Version  : 4.0.20
  * License  : MIT
  * Copyright: 2022 Naotoshi Fujita
  */
@@ -1207,17 +1207,18 @@ function Layout(Splide2, Components2, options) {
   }
 
   function init() {
+    rootRect = null;
     vertical = options.direction === TTB;
     style(root, "maxWidth", unit(options.width));
     style(track, resolve("paddingLeft"), cssPadding(false));
     style(track, resolve("paddingRight"), cssPadding(true));
-    resize(true);
+    resize();
   }
 
-  function resize(force) {
+  function resize() {
     var newRect = rect(root);
 
-    if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
+    if (!rootRect || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
       style(track, "height", cssTrackHeight());
       styleSlides(resolve("marginRight"), unit(options.gap));
       styleSlides("width", cssSlideWidth());
@@ -2825,7 +2826,6 @@ function Live(Splide2, Components2, options) {
       interval.start();
     } else {
       remove(sr);
-      interval.cancel();
     }
   }
 

+ 5 - 5
dist/js/splide.js

@@ -4,7 +4,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
 
 /*!
  * Splide.js
- * Version  : 4.0.21
+ * Version  : 4.0.20
  * License  : MIT
  * Copyright: 2022 Naotoshi Fujita
  */
@@ -1205,17 +1205,18 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     }
 
     function init() {
+      rootRect = null;
       vertical = options.direction === TTB;
       style(root, "maxWidth", unit(options.width));
       style(track, resolve("paddingLeft"), cssPadding(false));
       style(track, resolve("paddingRight"), cssPadding(true));
-      resize(true);
+      resize();
     }
 
-    function resize(force) {
+    function resize() {
       var newRect = rect(root);
 
-      if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
+      if (!rootRect || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
         style(track, "height", cssTrackHeight());
         styleSlides(resolve("marginRight"), unit(options.gap));
         styleSlides("width", cssSlideWidth());
@@ -2823,7 +2824,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
         interval.start();
       } else {
         remove(sr);
-        interval.cancel();
       }
     }
 

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


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


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


+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "@splidejs/splide",
-  "version": "4.0.21",
+  "version": "4.0.19",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "@splidejs/splide",
-      "version": "4.0.21",
+      "version": "4.0.19",
       "license": "MIT",
       "devDependencies": {
         "@babel/core": "^7.18.13",

+ 1 - 1
package.json

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

+ 5 - 7
src/js/components/Layout/Layout.ts

@@ -65,29 +65,27 @@ export function Layout( Splide: Splide, Components: Components, options: Options
 
   /**
    * Initializes the component on `mount` or `updated`.
-   * - Uses `max-width` for the root to prevent the slider from exceeding the parent element.
-   * - Needs to always resize the carousel in case that `refresh` is requested in multiple times at the same time.
+   * Uses `max-width` for the root to prevent the slider from exceeding the parent element.
    */
   function init(): void {
+    rootRect = null;
     vertical = options.direction === TTB;
 
     style( root, 'maxWidth', unit( options.width ) );
     style( track, resolve( 'paddingLeft' ), cssPadding( false ) );
     style( track, resolve( 'paddingRight' ), cssPadding( true ) );
 
-    resize( true );
+    resize();
   }
 
   /**
    * Updates dimensions of some elements when the carousel is resized.
    * Also checks the carousel size and emits `overflow` events when it exceeds the list width.
-   *
-   * @param force - Skips checking the root dimension change and always performs the resizing process.
    */
-  function resize( force?: boolean ): void {
+  function resize(): void {
     const newRect = rect( root );
 
-    if ( force || rootRect.width !== newRect.width || rootRect.height !== newRect.height ) {
+    if ( ! rootRect || rootRect.width !== newRect.width || rootRect.height !== newRect.height ) {
       style( track, 'height', cssTrackHeight() );
 
       styleSlides( resolve( 'marginRight' ), unit( options.gap ) );

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