Prechádzať zdrojové kódy

Optimize "refresh" event.

NaotoshiFujita 5 rokov pred
rodič
commit
97a33ee4c2

+ 4 - 6
dist/js/splide.js

@@ -1630,12 +1630,11 @@ function () {
   }
   /**
    * Destroy all Slide objects and clones and recreate them again.
-   * And then call "updated" event.
    */
   ;
 
   _proto.refresh = function refresh() {
-    this.emit('refresh').emit('updated', this._o);
+    this.emit('refresh').emit('resize');
     return this;
   }
   /**
@@ -3646,7 +3645,7 @@ var THROTTLE = 100;
   function bind() {
     Splide.on('resize load', throttle(function () {
       Splide.emit('resize');
-    }, THROTTLE), window).on('resize', resize).on('updated', init);
+    }, THROTTLE), window).on('resize', resize).on('updated refresh', init);
   }
   /**
    * Resize the list and slides including clones.
@@ -4294,11 +4293,10 @@ var PAUSE_FLAGS = {
      * Called when the component is mounted.
      */
     mount: function mount() {
-      apply(false);
       Splide.on('lazyload:loaded', function (img) {
         cover(img, false);
       });
-      Splide.on('updated', function () {
+      Splide.on('mounted updated refresh', function () {
         return apply(false);
       });
     },
@@ -4500,7 +4498,7 @@ var SIZE = 40;
       return onClick(true);
     }, prev).on('click', function () {
       return onClick(false);
-    }, next).on('mounted move updated', updateDisabled);
+    }, next).on('mounted move updated refresh', updateDisabled);
   }
   /**
    * Called when an arrow is clicked.

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/js/splide.min.js


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


+ 1 - 1
src/js/components/arrows/index.js

@@ -125,7 +125,7 @@ export default ( Splide, Components, name ) => {
 		Splide
 			.on( 'click', () => onClick( true ), prev )
 			.on( 'click', () => onClick( false ), next )
-			.on( 'mounted move updated', updateDisabled );
+			.on( 'mounted move updated refresh', updateDisabled );
 	}
 
 	/**

+ 1 - 2
src/js/components/cover/index.js

@@ -41,9 +41,8 @@ export default ( Splide, Components ) => {
 		 * Called when the component is mounted.
 		 */
 		mount() {
-			apply( false );
 			Splide.on( 'lazyload:loaded', img => { cover( img, false ) } );
-			Splide.on( 'updated', () => apply( false ) );
+			Splide.on( 'mounted updated refresh', () => apply( false ) );
 		},
 
 		/**

+ 1 - 1
src/js/components/layout/index.js

@@ -80,7 +80,7 @@ export default ( Splide, Components ) => {
 		Splide
 			.on( 'resize load', throttle( () => { Splide.emit( 'resize' ) }, THROTTLE ), window )
 			.on( 'resize', resize )
-			.on( 'updated', init );
+			.on( 'updated refresh', init );
 	}
 
 	/**

+ 1 - 2
src/js/splide.js

@@ -193,10 +193,9 @@ export default class Splide {
 
 	/**
 	 * Destroy all Slide objects and clones and recreate them again.
-	 * And then call "updated" event.
 	 */
 	refresh() {
-		this.emit( 'refresh' ).emit( 'updated', this._o );
+		this.emit( 'refresh' ).emit( 'resize' );
 		return this;
 	}
 

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov