From 8b2f2c063c65278580d9469b00d9e67f01caaffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Tue, 25 Oct 2022 10:18:22 +0000 Subject: [PATCH] fix: profile module items show click effect on scroll --- .../modules/profile/page/profile-page-section.html | 7 ++++--- .../modules/profile/page/profile-page-section.scss | 11 ++++++++++- src/app/util/element-size-change.directive.ts | 14 +++++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/app/modules/profile/page/profile-page-section.html b/src/app/modules/profile/page/profile-page-section.html index 750ef797..9273de78 100644 --- a/src/app/modules/profile/page/profile-page-section.html +++ b/src/app/modules/profile/page/profile-page-section.html @@ -56,9 +56,10 @@ (); + @Input() elementSizeChangeDebounce?: number; + + debounceStamp = 0; + private resizeObserver: ResizeObserver; constructor(private elementRef: ElementRef) {} ngOnInit() { this.resizeObserver = new ResizeObserver(elements => { - if (!elements[0]) return; + const stamp = Date.now(); + if ( + !elements[0] || + (this.elementSizeChangeDebounce && + stamp - this.debounceStamp < this.elementSizeChangeDebounce) + ) + return; + this.debounceStamp = stamp; this.elementSizeChange.emit(elements[0]); }); this.resizeObserver.observe(this.elementRef.nativeElement);