Browse Source

Bug Fix: Pagination should correspond with each breakpoint options(#40).

NaotoshiFujita 5 years ago
parent
commit
5e217cdc1c

+ 7 - 6
dist/js/splide.esm.js

@@ -4679,7 +4679,7 @@ var UPDATE_EVENT = 'updated.page refresh.page';
     mounted: function mounted() {
     mounted: function mounted() {
       var index = Splide.index;
       var index = Splide.index;
       Splide.emit(name + ":mounted", data, this.getItem(index));
       Splide.emit(name + ":mounted", data, this.getItem(index));
-      update(index, -1);
+      updateAttributes(index, -1);
     },
     },
 
 
     /**
     /**
@@ -4693,9 +4693,10 @@ var UPDATE_EVENT = 'updated.page refresh.page';
         data.items.forEach(function (item) {
         data.items.forEach(function (item) {
           Splide.off('click', item.button);
           Splide.off('click', item.button);
         });
         });
-      }
+      } // Do not remove UPDATE events to recreate pagination if needed.
+
 
 
-      Splide.off(ATTRIBUTES_UPDATE_EVENT).off(UPDATE_EVENT);
+      Splide.off(ATTRIBUTES_UPDATE_EVENT);
       data = {};
       data = {};
     },
     },
 
 
@@ -4721,11 +4722,11 @@ var UPDATE_EVENT = 'updated.page refresh.page';
 
 
   };
   };
   /**
   /**
-   * Listen some events.
+   * Listen to some events.
    */
    */
 
 
   function bind() {
   function bind() {
-    Splide.on(ATTRIBUTES_UPDATE_EVENT, update).on(UPDATE_EVENT, function () {
+    Splide.on(ATTRIBUTES_UPDATE_EVENT, updateAttributes).on(UPDATE_EVENT, function () {
       Pagination.destroy();
       Pagination.destroy();
 
 
       if (Splide.options.pagination) {
       if (Splide.options.pagination) {
@@ -4742,7 +4743,7 @@ var UPDATE_EVENT = 'updated.page refresh.page';
    */
    */
 
 
 
 
-  function update(index, prevIndex) {
+  function updateAttributes(index, prevIndex) {
     var prev = Pagination.getItem(prevIndex);
     var prev = Pagination.getItem(prevIndex);
     var curr = Pagination.getItem(index);
     var curr = Pagination.getItem(index);
     var active = STATUS_CLASSES.active;
     var active = STATUS_CLASSES.active;

+ 7 - 6
dist/js/splide.js

@@ -4669,7 +4669,7 @@ var UPDATE_EVENT = 'updated.page refresh.page';
     mounted: function mounted() {
     mounted: function mounted() {
       var index = Splide.index;
       var index = Splide.index;
       Splide.emit(name + ":mounted", data, this.getItem(index));
       Splide.emit(name + ":mounted", data, this.getItem(index));
-      update(index, -1);
+      updateAttributes(index, -1);
     },
     },
 
 
     /**
     /**
@@ -4683,9 +4683,10 @@ var UPDATE_EVENT = 'updated.page refresh.page';
         data.items.forEach(function (item) {
         data.items.forEach(function (item) {
           Splide.off('click', item.button);
           Splide.off('click', item.button);
         });
         });
-      }
+      } // Do not remove UPDATE events to recreate pagination if needed.
+
 
 
-      Splide.off(ATTRIBUTES_UPDATE_EVENT).off(UPDATE_EVENT);
+      Splide.off(ATTRIBUTES_UPDATE_EVENT);
       data = {};
       data = {};
     },
     },
 
 
@@ -4711,11 +4712,11 @@ var UPDATE_EVENT = 'updated.page refresh.page';
 
 
   };
   };
   /**
   /**
-   * Listen some events.
+   * Listen to some events.
    */
    */
 
 
   function bind() {
   function bind() {
-    Splide.on(ATTRIBUTES_UPDATE_EVENT, update).on(UPDATE_EVENT, function () {
+    Splide.on(ATTRIBUTES_UPDATE_EVENT, updateAttributes).on(UPDATE_EVENT, function () {
       Pagination.destroy();
       Pagination.destroy();
 
 
       if (Splide.options.pagination) {
       if (Splide.options.pagination) {
@@ -4732,7 +4733,7 @@ var UPDATE_EVENT = 'updated.page refresh.page';
    */
    */
 
 
 
 
-  function update(index, prevIndex) {
+  function updateAttributes(index, prevIndex) {
     var prev = Pagination.getItem(prevIndex);
     var prev = Pagination.getItem(prevIndex);
     var curr = Pagination.getItem(index);
     var curr = Pagination.getItem(index);
     var active = STATUS_CLASSES.active;
     var active = STATUS_CLASSES.active;

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


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


+ 7 - 5
src/js/components/pagination/index.js

@@ -81,7 +81,7 @@ export default ( Splide, Components, name ) => {
 		mounted() {
 		mounted() {
 			const index = Splide.index;
 			const index = Splide.index;
 			Splide.emit( `${ name }:mounted`, data, this.getItem( index ) );
 			Splide.emit( `${ name }:mounted`, data, this.getItem( index ) );
-			update( index, -1 );
+			updateAttributes( index, -1 );
 		},
 		},
 
 
 		/**
 		/**
@@ -95,7 +95,9 @@ export default ( Splide, Components, name ) => {
 				data.items.forEach( item => { Splide.off( 'click', item.button ) } );
 				data.items.forEach( item => { Splide.off( 'click', item.button ) } );
 			}
 			}
 
 
-			Splide.off( ATTRIBUTES_UPDATE_EVENT ).off( UPDATE_EVENT );
+			// Do not remove UPDATE events to recreate pagination if needed.
+			Splide.off( ATTRIBUTES_UPDATE_EVENT );
+
 			data = {};
 			data = {};
 		},
 		},
 
 
@@ -121,11 +123,11 @@ export default ( Splide, Components, name ) => {
 	};
 	};
 
 
 	/**
 	/**
-	 * Listen some events.
+	 * Listen to some events.
 	 */
 	 */
 	function bind() {
 	function bind() {
 		Splide
 		Splide
-			.on( ATTRIBUTES_UPDATE_EVENT, update )
+			.on( ATTRIBUTES_UPDATE_EVENT, updateAttributes )
 			.on( UPDATE_EVENT, () => {
 			.on( UPDATE_EVENT, () => {
 				Pagination.destroy();
 				Pagination.destroy();
 
 
@@ -142,7 +144,7 @@ export default ( Splide, Components, name ) => {
 	 * @param {number} index     - Active index.
 	 * @param {number} index     - Active index.
 	 * @param {number} prevIndex - Prev index.
 	 * @param {number} prevIndex - Prev index.
 	 */
 	 */
-	function update( index, prevIndex ) {
+	function updateAttributes( index, prevIndex ) {
 		const prev   = Pagination.getItem( prevIndex );
 		const prev   = Pagination.getItem( prevIndex );
 		const curr   = Pagination.getItem( index );
 		const curr   = Pagination.getItem( index );
 		const active = STATUS_CLASSES.active;
 		const active = STATUS_CLASSES.active;

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