Slider container: Fix error about observer
This commit is contained in:
parent
5948d61a47
commit
8d6522270c
|
@ -60,7 +60,7 @@ export class SliderContainerComponent implements OnInit, OnDestroy, AfterContent
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
if(this.observer) {
|
if(this.observer && typeof IntersectionObserver !== 'undefined') {
|
||||||
this.observer.disconnect();
|
this.observer.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,24 +78,26 @@ export class SliderContainerComponent implements OnInit, OnDestroy, AfterContent
|
||||||
}
|
}
|
||||||
|
|
||||||
setObserver() {
|
setObserver() {
|
||||||
let options = {
|
if(typeof IntersectionObserver !== 'undefined') {
|
||||||
root: null,
|
let options = {
|
||||||
rootMargin: '0px',
|
root: null,
|
||||||
threshold: 0.1
|
rootMargin: '0px',
|
||||||
};
|
threshold: 0.1
|
||||||
this.observer = new IntersectionObserver(entries => {
|
};
|
||||||
entries.forEach(entry => {
|
this.observer = new IntersectionObserver(entries => {
|
||||||
if (entry.isIntersecting && !this.initialized) {
|
entries.forEach(entry => {
|
||||||
this.stopped = false;
|
if (entry.isIntersecting && !this.initialized) {
|
||||||
this.start(0);
|
this.stopped = false;
|
||||||
this.initialized = true;
|
this.start(0);
|
||||||
} else {
|
this.initialized = true;
|
||||||
this.initialized = false;
|
} else {
|
||||||
this.stopped = true;
|
this.initialized = false;
|
||||||
}
|
this.stopped = true;
|
||||||
});
|
}
|
||||||
}, options);
|
});
|
||||||
this.observer.observe(this.element.nativeElement);
|
}, options);
|
||||||
|
this.observer.observe(this.element.nativeElement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
start(time: number) {
|
start(time: number) {
|
||||||
|
|
Loading…
Reference in New Issue