From 9c421d6aa27930d1cb9c1723ace246f8cbee68aa Mon Sep 17 00:00:00 2001 From: Heo Sangmin Date: Wed, 17 Oct 2018 00:02:53 +0900 Subject: [PATCH] fix(slick): keep slides, _addedSlides, _removeSlides when manually unslick called --- package.json | 2 +- src/package.json | 8 ++++---- src/slick.component.ts | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 628390a..861f2f2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/package.json b/src/package.json index 13c17fa..3ea044d 100644 --- a/src/package.json +++ b/src/package.json @@ -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" @@ -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" } diff --git a/src/slick.component.ts b/src/slick.component.ts index b706408..400528f 100755 --- a/src/slick.component.ts +++ b/src/slick.component.ts @@ -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 }); }); }); @@ -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 { @@ -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); + }); } } }