Update useBuildNode.ts

Added addition of the rect's top left coordinates to get equivalent behavior.
This commit is contained in:
Jonathan 2023-12-26 08:14:22 -06:00 committed by psychedelicious
parent 84a001720c
commit f6664960ca

View File

@ -38,11 +38,11 @@ export const useBuildNode = () => {
?.getBoundingClientRect();
if (rect) {
_x = rect.width / 2 - NODE_WIDTH / 2;
_y = rect.height / 2 - NODE_WIDTH / 2;
_x = rect.width / 2 - NODE_WIDTH / 2 + rect.left;
_y = rect.height / 2 - NODE_WIDTH / 2 + rect.top;
}
const position = flow.project({
const position = flow.screenToFlowPosition({
x: _x,
y: _y,
});