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

how to apply transform:scale to Draggable? #353

Open
linux019 opened this issue Jul 31, 2018 · 6 comments
Open

how to apply transform:scale to Draggable? #353

linux019 opened this issue Jul 31, 2018 · 6 comments

Comments

@linux019
Copy link

No description provided.

@MrDockal
Copy link
Contributor

You can pass scale property down to Draggable

<Draggable {...dragHandlers} scale={0.5}>
    <div className="box">I can be dragged anywhere</div>
</Draggable>

@yh54321
Copy link

yh54321 commented Feb 2, 2020

You can now do this by wrapping your <Draggable> component in a <div> styled with a scale transformation transform: scale(1.2);. Then add the 'scale' attribute to your draggable component with the same scale value: scale={1.2}.

This issue can be closed @STRML

@jamesonhill
Copy link

It doesn't seem like the <Draggable> component properly handles scaled containers while dragging. If you apply transform: scale(x, y) to the container element and supply that value to the scale prop, the cursor and the draggable element do no move in sync. See below example w/ 0.5 scale.

Screen.Recording.2021-02-18.at.3.04.17.PM.mov

@yh54321
Copy link

yh54321 commented Feb 20, 2021

@jamesonhill You can't use transform: scale(x, y); here, only transform: scale(x);. Did you implement this exactly as I advised in my comment? The value you pass as a prop must be the net scale on the component. It works perfectly for me.

@jamesonhill
Copy link

@yh54321 My issue ended up being caused by another library's usage of react-draggable (react-grid-layout/react-grid-layout#1393), not react-draggable itself.

@ronyland
Copy link

ronyland commented Mar 8, 2021

It doesn't seem like the <Draggable> component properly handles scaled containers while dragging. If you apply transform: scale(x, y) to the container element and supply that value to the scale prop, the cursor and the draggable element do no move in sync. See below example w/ 0.5 scale.

Screen.Recording.2021-02-18.at.3.04.17.PM.mov

I fixed it by updating the react-draggable from version 2.2.2 to version 4.4.3

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

5 participants