전략편집기 수정
This commit is contained in:
@@ -10,18 +10,24 @@ import {
|
||||
} from '../../utils/paletteDragSession';
|
||||
|
||||
/**
|
||||
* Tauri WebView — 드래그 중 전체 화면 overlay 가 pointer 이벤트·drop 을 수신
|
||||
* Tauri WebView — 드래그 overlay (라벨 위치는 ref 갱신, move 마다 React re-render 없음)
|
||||
*/
|
||||
export default function PaletteDragOverlay() {
|
||||
const [session, setSession] = useState<PaletteDragOverlaySession | null>(null);
|
||||
const [cursor, setCursor] = useState({ x: 0, y: 0 });
|
||||
const overlayRef = useRef<HTMLDivElement | null>(null);
|
||||
const labelRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
registerPaletteDragOverlay({
|
||||
mount: next => {
|
||||
setCursor({ x: next.x, y: next.y });
|
||||
setSession(next);
|
||||
requestAnimationFrame(() => {
|
||||
const label = labelRef.current;
|
||||
if (label) {
|
||||
label.style.left = `${next.x}px`;
|
||||
label.style.top = `${next.y}px`;
|
||||
}
|
||||
});
|
||||
},
|
||||
unmount: () => setSession(null),
|
||||
bindElement: el => {
|
||||
@@ -41,7 +47,7 @@ export default function PaletteDragOverlay() {
|
||||
try {
|
||||
overlayRef.current.setPointerCapture(session.pointerId);
|
||||
} catch {
|
||||
/* body capture fallback */
|
||||
/* ignore */
|
||||
}
|
||||
}, [session]);
|
||||
|
||||
@@ -49,7 +55,11 @@ export default function PaletteDragOverlay() {
|
||||
if (!session || e.pointerId !== session.pointerId) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setCursor({ x: e.clientX, y: e.clientY });
|
||||
const label = labelRef.current;
|
||||
if (label) {
|
||||
label.style.left = `${e.clientX}px`;
|
||||
label.style.top = `${e.clientY}px`;
|
||||
}
|
||||
notifyPaletteDragMove(e.clientX, e.clientY);
|
||||
}, [session]);
|
||||
|
||||
@@ -78,8 +88,9 @@ export default function PaletteDragOverlay() {
|
||||
onPointerCancel={onPointerCancel}
|
||||
>
|
||||
<div
|
||||
ref={labelRef}
|
||||
className="se-palette-drag-overlay-label"
|
||||
style={{ left: cursor.x, top: cursor.y }}
|
||||
style={{ left: session.x, top: session.y }}
|
||||
>
|
||||
{session.payload.label}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user