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

Allow controlled resizing #319

Open
yang opened this issue Jul 6, 2018 · 9 comments
Open

Allow controlled resizing #319

yang opened this issue Jul 6, 2018 · 9 comments

Comments

@yang
Copy link

yang commented Jul 6, 2018

Currently re-resizable exclusively owns the width/height during a resize. It would be powerful to make this controllable, so that users can implement (for instance) their own sizing (snapping, clamping, etc.) logic.

(As a hack for now, one can override the calculateNewSize method to always return auto, and then explicitly control the size of a grand-child div from the onResize callback.)

@jakub-chatrny
Copy link

One usecase where you can use it is when you have absolute position of box and you are resizing (left, top). You might want change (left, top) position.

@mdanka
Copy link
Contributor

mdanka commented Jul 20, 2018

This is also a problem when using a scale transform.

For example, with a scale of 2:
reresizable

An example implementation of this is how react-draggable exposes a DraggableCore element which truly doesn't manage any state, even while dragging: https://github.com/mzabriskie/react-draggable

As a workaround, you can use the "deprecated" updateSize method on the resizable instance to override the default sizing.

@jakub-chatrny
Copy link

jakub-chatrny commented Jul 20, 2018

Yep I face same issue using react-rnd (which extends re-resizable)
Thanks for providing workaround @mdanka !

@chathuraa
Copy link

Another use case is when implementing auto scroll functionality to sync resizing with scroll speed.

@chathuraa
Copy link

Hi @yang ,

Would you mind giving an example. Also how would I go about resizing the left edge?

Thanks,
Chat

@bokuweb
Copy link
Owner

bokuweb commented Dec 19, 2018

@yang @jakub-chatrny @chathuraa @mdanka #391 resizeRatio is added. Could you please try it?

@JoshuaCWebDeveloper
Copy link

It wasn't immediately clear to me from reading this ticket, so I just wanted to clarify that this functionality does appear to be currently implemented in the latest version (using the size property and the resize handlers).

@codebycarlos
Copy link

codebycarlos commented Jul 20, 2022

Agree with @JoshuaCWebDeveloper; this can be accomplished by using the size property, setting it with your own state (i.e. width, height), and then on the onResize event changing dimensions as desired by updating the state. Should probably close this issue.

@vincaslt
Copy link

It isn't really contolled, the problem is that it maintains internal state and does the sizing based on that. It does accept and synchronize outside state via props, but while resizing it's ignored and the internal state is used, meaning that I'm not really controlling the size, for instance I can't stop resizing at some point (e.g. reached some boundary), because the internal state keeps going.

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

8 participants