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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {inject, Injectable} from '@angular/core';
import {inject, Injectable, NgZone} from '@angular/core';
import {Subject} from 'rxjs';
import {ReaderAnnotationService} from '../features/annotations/annotation-renderer.service';

Expand Down Expand Up @@ -33,6 +33,7 @@ export class ReaderEventService {
private readonly SWIPE_THRESHOLD_PX = 50;

private annotationService = inject(ReaderAnnotationService);
private ngZone = inject(NgZone);

private view: any;
private viewCallbacks: ViewCallbacks | null = null;
Expand Down Expand Up @@ -395,7 +396,8 @@ export class ReaderEventService {
}

const minSpaceAbove = 120;
const showBelow = selectionTop < minSpaceAbove;
const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
const showBelow = isMobile || selectionTop < minSpaceAbove;

let popupY: number;
if (showBelow) {
Expand All @@ -406,10 +408,12 @@ export class ReaderEventService {

popupX = Math.max(100, Math.min(popupX, window.innerWidth - 150));

this.eventSubject.next({
type: 'text-selected',
detail: {text, cfi, range, index},
popupPosition: {x: popupX, y: popupY, showBelow}
this.ngZone.run(() => {
this.eventSubject.next({
type: 'text-selected',
detail: {text, cfi, range, index},
popupPosition: {x: popupX, y: popupY, showBelow}
});
});
}
}, 10);
Expand Down