forked from akai/readest
ue: make text highlighting unified on Desktop, Android and iOS (#256)
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user