mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
fix: profile module items show click effect on scroll
This commit is contained in:
committed by
Rainer Killinger
parent
bc4c3d78db
commit
8b2f2c063c
@@ -17,6 +17,7 @@ import {
|
||||
Directive,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
@@ -29,13 +30,24 @@ export class ElementSizeChangeDirective implements OnInit, OnDestroy {
|
||||
@Output()
|
||||
elementSizeChange = new EventEmitter<ResizeObserverEntry>();
|
||||
|
||||
@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);
|
||||
|
||||
Reference in New Issue
Block a user