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

[QUESTION] Force updating moveable control box. #281

Closed
vin-ce opened this issue Jul 12, 2020 · 4 comments
Closed

[QUESTION] Force updating moveable control box. #281

vin-ce opened this issue Jul 12, 2020 · 4 comments
Labels
question Further information is requested React

Comments

@vin-ce
Copy link

vin-ce commented Jul 12, 2020

Environments

  • Framework name: React
  • Framework version: 16.13.1
  • Moveable Component version: 0.19.2

Description

I have an app with undo/ redo. Upon undo/ redo, the component's stylings (height, width etc) and frame (transform, rotate) are all updated. The Moveable component is saved in a ref variable (accessed via moveable.current) that is set to null, and after the primary component has been updated (and is re-rendered), the Moveable component is assigned a value again with the updated target.

updating-control-box

However, as you can see, the frame is not updated. I noticed updateRect() and updateTarget() as methods. If I wanted refresh the moveable control box, do I use those? If so, how do I access them when I'm using Moveable as a component?

Thank you for this incredible project!

@daybrush daybrush added question Further information is requested React labels Jul 12, 2020
@daybrush
Copy link
Owner

@vin-ce

Yes. Calling updateRect will change the moveable box styles.

Access it with <Moveable ref={??} />

@vin-ce
Copy link
Author

vin-ce commented Jul 12, 2020

Perfect thank you so much!

@vin-ce vin-ce closed this as completed Jul 12, 2020
@Darkside73
Copy link

In some reason it works only if call like that:

    setTimeout(() => {
      moveable.updateRect()
    })

@FlandiaYingman
Copy link

Hi, I am new to React. I addd some dependencies to useEffect(() => {setTarget(...)}. When the dependencies are changed, React re-renders the <Moveable> automatically. I guess this is better than updating moveable box manually by calling updateRect().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested React
Projects
None yet
Development

No branches or pull requests

4 participants