我在滚动时折叠了我的标题,但它在某些时候闪烁
这是我的代码
public getScrollPosition(event) {
if (event) {
return event.getElementRef().nativeElement.scrollTop;
} else {
return window.scrollY;
}
}
ngOnInit(): void {
// this.init();
this.scrollDispatcher.scrolled()
.pipe(map((event: CdkScrollable) => this.getScrollPosition(event)))
.subscribe(scrollTop => this.ngZone.run(() => this.shrinkHeader = scrollTop > this.SHRINK_TOP_SCROLL_POSITION ? true : false));
}