Skip to content

Commit

Permalink
Bug Fix: add() and remove() didn't work correctly in loop mode(#145).
Browse files Browse the repository at this point in the history
  • Loading branch information
NaotoshiFujita committed Nov 20, 2020
1 parent 5febf84 commit 55782b6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
8 changes: 5 additions & 3 deletions dist/js/splide.esm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Splide.js
* Version : 2.4.17
* Version : 2.4.18
* License : MIT
* Copyright: 2020 Naotoshi Fujita
*/
Expand Down Expand Up @@ -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;
}
/**
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions dist/js/splide.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Splide.js
* Version : 2.4.17
* Version : 2.4.18
* License : MIT
* Copyright: 2020 Naotoshi Fujita
*/
Expand Down Expand Up @@ -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;
}
/**
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions dist/js/splide.min.js

Large diffs are not rendered by default.

Binary file modified dist/js/splide.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/js/components/clones/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default ( Splide, Components ) => {
init();

Splide
.on( 'refresh:before', () => { this.destroy() } )
.on( 'refresh', init )
.on( 'resize', () => {
if ( cloneCount !== getCloneCount() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/splide.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 55782b6

Please sign in to comment.