Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centerNodeOnMove not working right when it is False #324

Open
AhmadYoussef opened this issue Jul 29, 2021 · 1 comment
Open

centerNodeOnMove not working right when it is False #324

AhmadYoussef opened this issue Jul 29, 2021 · 1 comment

Comments

@AhmadYoussef
Copy link

Thank lots for all the hard work. It really is a great library.

I would like to report a bug here:

After I updated the library to version 7.1.0, I got the bug that when I set centerNodeOnMove= false, the node does not move as it should.

So I switched back to V 7.0.0 to solve the problem ... but now when I select a node and click backspace while writing in input, the selected node is directly deleted ... so is there any way to turn off this event in version 7.0.0 using ref?

Otherwise, it would be nice if someone could solve the problem.

Hint:
I have tried all versions after 7.0.0 and I get the same error that the node is moved incorrectly when centerNodeOnMove= false

@AhmadYoussef
Copy link
Author

I did today a debug to the code and I found out that this line is rendering while the node is moving

position.current = { x: data.x || 0, y: data.y || 0, pointerOffset: null };

so it will rewrite the pointerOffset. so I decided to remove the assigned value and move it to useRef in this line

const position = useRef();

and I made it like this :

  const position = useRef({
    x: data.x || 0,
    y: data.y || 0,
    pointerOffset: null,
  });

but I am not sure if this will not work correctly with another function ... but I test it and it looks fine.

I hope you will fix the problem in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant