feat(annotator): responsive layout for the loupe (#3568)

This commit is contained in:
Huang Xin
2026-03-20 00:54:24 +08:00
committed by GitHub
parent 764acf59de
commit 1f4f5f8a6d
5 changed files with 29 additions and 54 deletions
@@ -9,11 +9,7 @@ import { useReaderStore } from '@/store/readerStore';
import { useSettingsStore } from '@/store/settingsStore';
import { useResponsiveSize } from '@/hooks/useResponsiveSize';
import { useAnnotationEditor } from '../../hooks/useAnnotationEditor';
import {
getEffectiveLoupePoint,
getExternalDragHandle,
getHighlightColorHex,
} from '../../utils/annotatorUtil';
import { getExternalDragHandle, getHighlightColorHex } from '../../utils/annotatorUtil';
import MagnifierLoupe from './MagnifierLoupe';
interface HandleProps {
@@ -253,17 +249,17 @@ const AnnotationRangeEditor: React.FC<AnnotationRangeEditorProps> = ({
return null;
}
const effectiveLoupePoint = getEffectiveLoupePoint(loupePoint, externalDragPoint);
const loupeDragPoint = externalDragPoint;
const effectiveLoupePoint = loupePoint ?? loupeDragPoint;
const activeHandle =
draggingHandle ??
(externalDragPoint ? getExternalDragHandle(externalDragPoint, currentStart, currentEnd) : null);
draggingHandle ?? getExternalDragHandle(currentStart, currentEnd, loupeDragPoint);
const showLoupe = effectiveLoupePoint !== null && appService?.isMobile && !viewSettings?.vertical;
return (
<div className='pointer-events-none fixed inset-0 z-50'>
<Handle
hidden={activeHandle === 'end'}
hidden={activeHandle === 'end' || loupeDragPoint !== null}
position={currentStart}
isVertical={isVertical}
type='start'
@@ -273,7 +269,7 @@ const AnnotationRangeEditor: React.FC<AnnotationRangeEditorProps> = ({
onDragEnd={handleDragEnd}
/>
<Handle
hidden={activeHandle === 'start'}
hidden={activeHandle === 'start' || loupeDragPoint !== null}
position={currentEnd}
isVertical={isVertical}
type='end'