Skip to content

Commit

Permalink
fix(slick): keep slides, _addedSlides, _removeSlides when manually un…
Browse files Browse the repository at this point in the history
…slick called
  • Loading branch information
leo6104 committed Oct 16, 2018
1 parent f6df42d commit 9c421d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-slick-carousel",
"version": "0.4.2",
"version": "0.4.3",
"scripts": {
"build": "ng build ngx-slick-carousel",
"docs": "npm run docs:build",
Expand Down
8 changes: 4 additions & 4 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-slick-carousel",
"version": "0.4.2",
"version": "0.4.3",
"repository": {
"type": "git",
"url": "https://github.com/leo6104/ngx-slick-carousel"
Expand All @@ -19,9 +19,9 @@
"module": "ngx-slick.js",
"typings": "ngx-slick.d.ts",
"peerDependencies": {
"@angular/core": "^6.0.0",
"@angular/common": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/core": "^6.0.0 || ^7.0.0",
"@angular/common": "^6.0.0 || ^7.0.0",
"@angular/forms": "^6.0.0 || ^7.0.0",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
}
Expand Down
9 changes: 5 additions & 4 deletions src/slick.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class SlickCarouselComponent implements OnDestroy, OnChanges, AfterViewIn
this.$instance.on('destroy', (event, slick) => {
this.zone.run(() => {
this.destroy.emit({event, slick});
this.unslick(); // in case of user call element.slick('unslick') directly, we need to call `unslick()` in here
});
});
});
Expand Down Expand Up @@ -201,11 +202,9 @@ export class SlickCarouselComponent implements OnDestroy, OnChanges, AfterViewIn
this.zone.runOutsideAngular(() => {
this.$instance.slick('unslick');
});
this.$instance = undefined;
}
this.initialized = false;
this.slides = [];
this._addedSlides = [];
this._removedSlides = [];
}

ngOnChanges(changes: SimpleChanges): void {
Expand All @@ -215,7 +214,9 @@ export class SlickCarouselComponent implements OnDestroy, OnChanges, AfterViewIn
const newOptions = Object.assign({}, changes['config'].currentValue);
delete newOptions['refresh'];

this.$instance.slick('slickSetOption', newOptions, refresh);
this.zone.runOutsideAngular(() => {
this.$instance.slick('slickSetOption', newOptions, refresh);
});
}
}
}
Expand Down

0 comments on commit 9c421d6

Please sign in to comment.