Skip to content

Commit

Permalink
fix(carousel): update the view when there is a change
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Feb 13, 2019
1 parent b6cbc32 commit f330fb9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/carousel/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
} from '@angular/core';
import { Platform, LyTheme2, toBoolean, ThemeVariables, DirAlias } from '@alyle/ui';
import * as _chroma from 'chroma-js';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

/** @docs-private */
const chroma = _chroma;
Expand Down Expand Up @@ -160,6 +162,10 @@ export class LyCarousel implements OnInit, AfterViewInit, OnDestroy {
_selectedElement: HTMLElement;
private _touch: boolean;
private _slideClass: string;

/** Emits whenever the component is destroyed. */
private readonly _destroy = new Subject<void>();

@Input()
set touch(val: boolean) {
const newVal = toBoolean(val);
Expand Down Expand Up @@ -190,6 +196,7 @@ export class LyCarousel implements OnInit, AfterViewInit, OnDestroy {
if (Platform.isBrowser) {
this._resetInterval();
}
this.lyItems.changes.pipe(takeUntil(this._destroy)).subscribe(() => this._markForCheck());
}

ngAfterViewInit() {
Expand All @@ -200,6 +207,8 @@ export class LyCarousel implements OnInit, AfterViewInit, OnDestroy {
}

ngOnDestroy() {
this._destroy.next();
this._destroy.complete();
if (Platform.isBrowser) {
this.stop();
}
Expand Down

0 comments on commit f330fb9

Please sign in to comment.