ue: make text highlighting unified on Desktop, Android and iOS (#256)

This commit is contained in:
Huang Xin
2025-01-26 00:57:59 +01:00
committed by GitHub
parent dc8cae5c77
commit a827316982
2 changed files with 5 additions and 4 deletions
@@ -76,7 +76,7 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
const transPopupHeight = Math.min(360, maxHeight);
const annotPopupWidth = useResponsiveSize(280);
const annotPopupHeight = useResponsiveSize(44);
const androidSelectionHandlerHeight = 16;
const androidSelectionHandlerHeight = 8;
const onLoad = (event: Event) => {
const detail = (event as CustomEvent).detail;
@@ -87,8 +87,6 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
};
const makeSelection = (sel: Selection, rebuildRange = false) => {
isTextSelected.current = true;
isUpToShowPopup.current = true;
const range = sel.getRangeAt(0);
if (rebuildRange) {
sel.removeAllRanges();
@@ -117,6 +115,9 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
} else if (!isUpToShowPopup.current) {
isTextSelected.current = false;
setShowAnnotPopup(false);
setShowWiktionaryPopup(false);
setShowWikipediaPopup(false);
setShowDeepLPopup(false);
}
};
const handleTouchmove = () => {
+1 -1
View File
@@ -95,7 +95,7 @@ export const getPosition = (target: Range | Element, rect: Rect, isVertical: boo
dir: 'up',
} as Position;
const end = {
point: { x: (last.left + last.right) / 2 - rect.left, y: last.bottom - rect.top },
point: { x: (last.left + last.right) / 2 - rect.left, y: last.bottom - rect.top + 6 },
dir: 'down',
} as Position;
const startInView = pointIsInView(start.point);