Forráskód Böngészése

Get width of slides from the first slide when `fixedWidth` is enabled.

NaotoshiFujita 3 éve
szülő
commit
a752c18891

+ 2 - 15
dist/js/splide.js

@@ -283,18 +283,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     });
   }
 
-  function measure(parent, value) {
-    if (isString(value)) {
-      var div = create("div", {
-        style: "width: " + value + "; position: absolute;"
-      }, parent);
-      value = rect(div).width;
-      remove(div);
-    }
-
-    return value;
-  }
-
   function parseHtml(html) {
     return child(new DOMParser().parseFromString(html, "text/html").body);
   }
@@ -1322,10 +1310,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       if (!Splide2.is(LOOP)) {
         clones2 = 0;
       } else if (!clones2) {
-        var fixedSize = measure(Elements.list, options[resolve("fixedWidth")]);
+        var fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0);
         var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
-        var baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
-        clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2);
+        clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
       }
 
       return clones2;

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/js/splide.min.js


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


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/js/splide.min.js.map


+ 3 - 5
src/js/components/Clones/Clones.ts

@@ -3,7 +3,7 @@ import { LOOP } from '../../constants/types';
 import { EventInterface } from '../../constructors';
 import { Splide } from '../../core/Splide/Splide';
 import { BaseComponent, Components, Options } from '../../types';
-import { addClass, append, before, ceil, empty, measure, pad, push, rect, remove } from '../../utils';
+import { addClass, append, before, ceil, empty, pad, push, rect, remove } from '../../utils';
 
 
 /**
@@ -128,11 +128,9 @@ export function Clones( Splide: Splide, Components: Components, options: Options
     if ( ! Splide.is( LOOP ) ) {
       clones = 0;
     } else if ( ! clones ) {
-      const fixedSize  = measure( Elements.list, options[ resolve( 'fixedWidth' ) ] );
+      const fixedSize  = options[ resolve( 'fixedWidth' ) ] && Components.Layout.slideSize( 0 );
       const fixedCount = fixedSize && ceil( rect( Elements.track )[ resolve( 'width' ) ] / fixedSize );
-      const baseCount  = fixedCount || ( options[ resolve( 'autoWidth' ) ] && Splide.length ) || options.perPage;
-
-      clones = baseCount * ( options.drag ? ( options.flickMaxPages || 1 ) + 1 : 2 );
+      clones = fixedCount || ( options[ resolve( 'autoWidth' ) ] && Splide.length ) || options.perPage;
     }
 
     return clones;

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott