Skip to content

Commit 1922b43

Browse files
Decreased polling delay to 1ms
1 parent d8c57d1 commit 1922b43

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/text-annotator/src/SelectionHandler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const SelectionHandler = (
5555

5656
const onSelectStart = (evt: Event) => {
5757
isContextMenuOpen = false;
58-
58+
5959
if (isLeftClick === false)
6060
return;
6161

@@ -250,7 +250,7 @@ export const SelectionHandler = (
250250
let isCollapsed = sel?.isCollapsed;
251251
const shouldStopPolling = () => isCollapsed || stopPolling;
252252

253-
const pollingDelayMs = 2;
253+
const pollingDelayMs = 10;
254254
const stopPollingInMs = 50;
255255
setTimeout(() => stopPolling = true, stopPollingInMs);
256256

@@ -264,12 +264,12 @@ export const SelectionHandler = (
264264

265265
if (sel?.isCollapsed) return;
266266

267-
// When selecting the initial word, Chrome Android fires `contextmenu`
267+
// When selecting the initial word, Chrome Android fires `contextmenu`
268268
// before selectionChanged.
269269
if (!currentTarget || currentTarget.selector.length === 0) {
270270
onSelectionChange(evt);
271271
}
272-
272+
273273
upsertCurrentTarget();
274274

275275
selection.userSelect(currentTarget.annotation, clonePointerEvent(evt));
@@ -301,15 +301,15 @@ export const SelectionHandler = (
301301

302302
selection.userSelect(currentTarget.annotation, cloneKeyboardEvent(evt));
303303
}
304-
304+
305305
document.removeEventListener('selectionchange', onSelected);
306306

307307
// Sigh... this needs a delay to work. But doesn't seem reliable.
308308
}, 100);
309309

310310
// Listen to the change event that follows
311311
document.addEventListener('selectionchange', onSelected);
312-
312+
313313
// Start selection!
314314
onSelectStart(evt);
315315
}

0 commit comments

Comments
 (0)