Przeglądaj źródła

Add the updateOnMove option which changes the update timing of adding is-active/is-visible classes.

NaotoshiFujita 5 lat temu
rodzic
commit
69afccae26

+ 12 - 2
dist/js/splide.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 1.2.5
+ * Version  : 1.2.7
  * License  : MIT
  * Copyright: 2019 Naotoshi Fujita
  */
@@ -657,6 +657,14 @@ var DEFAULTS = {
    */
   trimSpace: true,
 
+  /**
+   * Slide status is updated after move as default.
+   * If true, it will be updated before move.
+   *
+   * @type {boolean}
+   */
+  updateOnMove: false,
+
   /**
    * Breakpoints definitions.
    *
@@ -2087,7 +2095,9 @@ function slide_Slide(index, realIndex, slide, Splide) {
         slide.id = Splide.root.id + "-slide" + (number < 10 ? '0' + number : number);
       }
 
-      Splide.on('mounted moved updated', function () {
+      var events = 'mounted updated ' + (Splide.options.updateOnMove ? 'move' : 'moved');
+      console.log(events);
+      Splide.on(events, function () {
         _this.update(_this.isActive(), false);
 
         _this.update(_this.isVisible(), true);

Plik diff jest za duży
+ 1 - 1
dist/js/splide.min.js


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


+ 1 - 1
package.json

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

+ 8 - 4
src/js/components/slides/slide.js

@@ -66,10 +66,14 @@ export default function Slide( index, realIndex, slide, Splide ) {
 				slide.id = `${ Splide.root.id }-slide${ number < 10 ? '0' + number : number }`;
 			}
 
-			Splide.on( 'mounted moved updated', () => {
-				this.update( this.isActive(), false );
-				this.update( this.isVisible(), true );
-			} ).on( 'resize', () => { this.update( this.isVisible(), true ) } );
+			const events = 'mounted updated ' + ( Splide.options.updateOnMove ? 'move' : 'moved' );
+
+			Splide
+				.on( events, () => {
+					this.update( this.isActive(), false );
+					this.update( this.isVisible(), true );
+				} )
+				.on( 'resize', () => { this.update( this.isVisible(), true ) } );
 		},
 
 		/**

+ 8 - 0
src/js/constants/defaults.js

@@ -280,6 +280,14 @@ export const DEFAULTS = {
 	 */
 	trimSpace: true,
 
+	/**
+	 * Slide status is updated after move as default.
+	 * If true, it will be updated before move.
+	 *
+	 * @type {boolean}
+	 */
+	updateOnMove: false,
+
 	/**
 	 * Breakpoints definitions.
 	 *

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików