fix(readers): fix mobile text selection (#2667)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {Component, EventEmitter, HostListener, Input, Output} from '@angular/core';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {ReaderIconComponent} from './icon.component';
|
||||
|
||||
@@ -134,9 +134,27 @@ export class TextSelectionPopupComponent {
|
||||
this.hasPreview = false;
|
||||
}
|
||||
|
||||
onDismiss(event: Event): void {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
@HostListener('document:touchend', ['$event'])
|
||||
onDocumentTouchEnd(event: TouchEvent): void {
|
||||
if (!window.matchMedia('(pointer: coarse)').matches) {
|
||||
return;
|
||||
}
|
||||
|
||||
const target = event.target;
|
||||
if (target instanceof Element && target.closest('.text-selection-popup, foliate-view')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onDismiss();
|
||||
}
|
||||
|
||||
onDismiss(event?: Event): void {
|
||||
if (!this.visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
event?.stopPropagation();
|
||||
event?.preventDefault();
|
||||
|
||||
if (this.hasPreview) {
|
||||
this.action.emit({
|
||||
|
||||
Reference in New Issue
Block a user