Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions UI/Web/src/app/cards/entity-card/entity-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Component,
computed,
DestroyRef,
ElementRef,
HostListener,
inject,
input,
Expand Down Expand Up @@ -66,6 +67,7 @@ import {UserProgressUpdateEvent} from "../../_models/events/user-progress-update
export class EntityCardComponent<T> implements OnInit {
private readonly cdRef = inject(ChangeDetectorRef);
private readonly destroyRef = inject(DestroyRef);
private readonly elementRef = inject(ElementRef);
private readonly scrollService = inject(ScrollService);
private readonly themeService = inject(ThemeService);
private readonly messageHub = inject(MessageHubService);
Expand Down Expand Up @@ -255,6 +257,18 @@ export class EntityCardComponent<T> implements OnInit {

ngOnInit() {
this.setupProgressTracking();
const el = this.elementRef.nativeElement;
const onTouchMove = () => {
if (!this.config().allowSelection) return;
this.selectionInProgress = false;
this.cdRef.markForCheck();
};
el.addEventListener('touchmove', onTouchMove, { passive: true });
this.destroyRef.onDestroy(() => el.removeEventListener('touchmove', onTouchMove));

const onTouchStart = (event: TouchEvent) => this.onTouchStart(event);
el.addEventListener('touchstart', onTouchStart, { passive: true });
this.destroyRef.onDestroy(() => el.removeEventListener('touchstart', onTouchStart));
}

private setupProgressTracking() {
Expand Down Expand Up @@ -307,14 +321,6 @@ export class EntityCardComponent<T> implements OnInit {
this.progressUpdated.emit(result);
}

@HostListener('touchmove')
onTouchMove() {
if (!this.config().allowSelection) return;
this.selectionInProgress = false;
this.cdRef.markForCheck();
}

@HostListener('touchstart', ['$event'])
onTouchStart(event: TouchEvent) {
if (!this.config().allowSelection) return;
this.prevTouchTime = event.timeStamp;
Expand Down