Browse Source

Bug Fix: add() and remove() didn't work correctly in loop mode(#145).

NaotoshiFujita 4 years ago
parent
commit
55782b60b2

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

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 2.4.17
+ * Version  : 2.4.18
  * License  : MIT
  * Copyright: 2020 Naotoshi Fujita
  */
@@ -1684,7 +1684,7 @@ var Splide = /*#__PURE__*/function () {
   ;
 
   _proto.refresh = function refresh() {
-    this.emit('refresh').emit('resize');
+    this.emit('refresh:before').emit('refresh').emit('resize');
     return this;
   }
   /**
@@ -3097,7 +3097,9 @@ var abs = Math.abs;
 
       if (Splide.is(LOOP)) {
         init();
-        Splide.on('refresh', init).on('resize', function () {
+        Splide.on('refresh:before', function () {
+          _this.destroy();
+        }).on('refresh', init).on('resize', function () {
           if (cloneCount !== getCloneCount()) {
             // Destroy before refresh not to collect clones by the Elements component.
             _this.destroy();

+ 5 - 3
dist/js/splide.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 2.4.17
+ * Version  : 2.4.18
  * License  : MIT
  * Copyright: 2020 Naotoshi Fujita
  */
@@ -1697,7 +1697,7 @@ var Splide = /*#__PURE__*/function () {
   ;
 
   _proto.refresh = function refresh() {
-    this.emit('refresh').emit('resize');
+    this.emit('refresh:before').emit('refresh').emit('resize');
     return this;
   }
   /**
@@ -3110,7 +3110,9 @@ var abs = Math.abs;
 
       if (Splide.is(LOOP)) {
         init();
-        Splide.on('refresh', init).on('resize', function () {
+        Splide.on('refresh:before', function () {
+          _this.destroy();
+        }).on('refresh', init).on('resize', function () {
           if (cloneCount !== getCloneCount()) {
             // Destroy before refresh not to collect clones by the Elements component.
             _this.destroy();

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


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


+ 1 - 1
package-lock.json

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

+ 1 - 1
package.json

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

+ 1 - 0
src/js/components/clones/index.js

@@ -55,6 +55,7 @@ export default ( Splide, Components ) => {
 				init();
 
 				Splide
+					.on( 'refresh:before', () => { this.destroy() } )
 					.on( 'refresh', init )
 					.on( 'resize', () => {
 						if ( cloneCount !== getCloneCount() ) {

+ 1 - 1
src/js/splide.js

@@ -200,7 +200,7 @@ export default class Splide {
 	 * Destroy all Slide objects and clones and recreate them again.
 	 */
 	refresh() {
-		this.emit( 'refresh' ).emit( 'resize' );
+		this.emit( 'refresh:before' ).emit( 'refresh' ).emit( 'resize' );
 		return this;
 	}
 

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