feat(selection): draggable

This commit is contained in:
moklick
2019-07-25 13:49:02 +02:00
parent 71c357ddfc
commit 562eddfa58
7 changed files with 83 additions and 27 deletions
+7 -7
View File
@@ -36,17 +36,17 @@ export default NodeComponent => (props) => {
return false;
}
const unscaledPos = {
const scaledClientX = {
x: e.clientX * (1 / k),
y: e.clientY * (1 / k)
}
const offsetX = unscaledPos.x - position.x - x;
const offsetY = unscaledPos.y - position.y - y;
const offsetX = scaledClientX.x - position.x - x;
const offsetY = scaledClientX.y - position.y - y;
setOffset({ x: offsetX, y: offsetY });
}}
onDrag={(e, d) => {
const unscaledPos = {
onDrag={(e) => {
const scaledClientX = {
x: e.clientX * (1 / k),
y: e.clientY * (1 / k)
}
@@ -55,8 +55,8 @@ export default NodeComponent => (props) => {
e.stopPropagation();
dispatch(updateNodePos(id, {
x: unscaledPos.x - x - offset.x,
y: unscaledPos.y - y - offset.y
x: scaledClientX.x - x - offset.x,
y: scaledClientX.y - y - offset.y
}));
}}
scale={k}