Jelajahi Sumber

Bug Fix: Recalculate padding and gap on resize(#80).

NaotoshiFujita 5 tahun lalu
induk
melakukan
2670673821

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

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 2.4.5
+ * Version  : 2.4.6
  * License  : MIT
  * Copyright: 2020 Naotoshi Fujita
  */
@@ -3356,6 +3356,14 @@ var abs = Math.abs;
      * Initialization.
      */
     init: function init() {
+      this.resize();
+    },
+
+    /**
+     * Resize gap and padding.
+     * This must be called on init.
+     */
+    resize: function resize() {
       options = Splide.options;
       track = Elements.track;
       this.gap = toPixel(root, options.gap);
@@ -3497,9 +3505,17 @@ var abs = Math.abs;
     margin: 'marginBottom',
 
     /**
-     * Init slider styles according to options.
+     * Initialization.
      */
     init: function init() {
+      this.resize();
+    },
+
+    /**
+     * Resize gap and padding.
+     * This must be called on init.
+     */
+    resize: function resize() {
       options = Splide.options;
       track = Elements.track;
       this.gap = toPixel(root, options.gap);
@@ -3782,6 +3798,7 @@ function createInterval(callback, interval, progress) {
 
   function resize() {
     var options = Splide.options;
+    Layout.resize();
     applyStyle(Elements.track, {
       height: unit(Layout.height)
     });

+ 19 - 2
dist/js/splide.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 2.4.5
+ * Version  : 2.4.6
  * License  : MIT
  * Copyright: 2020 Naotoshi Fujita
  */
@@ -3346,6 +3346,14 @@ var abs = Math.abs;
      * Initialization.
      */
     init: function init() {
+      this.resize();
+    },
+
+    /**
+     * Resize gap and padding.
+     * This must be called on init.
+     */
+    resize: function resize() {
       options = Splide.options;
       track = Elements.track;
       this.gap = toPixel(root, options.gap);
@@ -3487,9 +3495,17 @@ var abs = Math.abs;
     margin: 'marginBottom',
 
     /**
-     * Init slider styles according to options.
+     * Initialization.
      */
     init: function init() {
+      this.resize();
+    },
+
+    /**
+     * Resize gap and padding.
+     * This must be called on init.
+     */
+    resize: function resize() {
       options = Splide.options;
       track = Elements.track;
       this.gap = toPixel(root, options.gap);
@@ -3772,6 +3788,7 @@ function createInterval(callback, interval, progress) {
 
   function resize() {
     var options = Splide.options;
+    Layout.resize();
     applyStyle(Elements.track, {
       height: unit(Layout.height)
     });

File diff ditekan karena terlalu besar
+ 1 - 1
dist/js/splide.min.js


TEMPAT SAMPAH
dist/js/splide.min.js.gz


+ 1 - 1
package-lock.json

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

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@splidejs/splide",
-  "version": "2.4.5",
+  "version": "2.4.6",
   "description": "Splide is a lightweight and powerful slider without any dependencies.",
   "author": "Naotoshi Fujita",
   "license": "MIT",

+ 8 - 0
src/js/components/layout/directions/horizontal.js

@@ -66,6 +66,14 @@ export default ( Splide, Components ) => {
 		 * Initialization.
 		 */
 		init() {
+			this.resize();
+		},
+
+		/**
+		 * Resize gap and padding.
+		 * This must be called on init.
+		 */
+		resize() {
 			options = Splide.options;
 			track   = Elements.track;
 

+ 9 - 1
src/js/components/layout/directions/vertical.js

@@ -56,9 +56,17 @@ export default ( Splide, Components ) => {
 		margin: 'marginBottom',
 
 		/**
-		 * Init slider styles according to options.
+		 * Initialization.
 		 */
 		init() {
+			this.resize();
+		},
+
+		/**
+		 * Resize gap and padding.
+		 * This must be called on init.
+		 */
+		resize() {
 			options = Splide.options;
 			track   = Elements.track;
 

+ 2 - 0
src/js/components/layout/index.js

@@ -102,6 +102,8 @@ export default ( Splide, Components ) => {
 	function resize() {
 		const options = Splide.options;
 
+		Layout.resize();
+
 		applyStyle( Elements.track, { height: unit( Layout.height ) } );
 
 		const slideHeight = options.autoHeight ? null : unit( Layout.slideHeight() );

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini