fix point pos
This commit is contained in:
parent
09a87d3025
commit
131f82c5db
1 changed files with 9 additions and 2 deletions
|
|
@ -152,9 +152,16 @@ export function VisualEditor({ast, setAST, rt, setRT, errors, setErrors}: Visual
|
||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
}, [state]);
|
}, [state]);
|
||||||
|
|
||||||
|
function getCurrentPointer(e: MouseEvent) {
|
||||||
|
const bbox = refSVG.current!.getBoundingClientRect();
|
||||||
|
return {
|
||||||
|
x: e.pageX - bbox.left,
|
||||||
|
y: e.pageY - bbox.top,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const onMouseDown: MouseEventHandler<SVGSVGElement> = (e) => {
|
const onMouseDown: MouseEventHandler<SVGSVGElement> = (e) => {
|
||||||
const currentPointer = {x: e.pageX, y: e.pageY};
|
const currentPointer = getCurrentPointer(e);
|
||||||
|
|
||||||
if (e.button === 1) {
|
if (e.button === 1) {
|
||||||
checkPoint();
|
checkPoint();
|
||||||
|
|
@ -240,7 +247,7 @@ export function VisualEditor({ast, setAST, rt, setRT, errors, setErrors}: Visual
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMouseMove = (e: MouseEvent) => {
|
const onMouseMove = (e: MouseEvent) => {
|
||||||
const currentPointer = {x: e.pageX, y: e.pageY};
|
const currentPointer = getCurrentPointer(e);
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
const pointerDelta = subtractV2D(currentPointer, dragging.lastMousePos);
|
const pointerDelta = subtractV2D(currentPointer, dragging.lastMousePos);
|
||||||
setState(state => ({
|
setState(state => ({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue