Antdev Posted March 10, 2022 Share Posted March 10, 2022 Hello I would like to have a modal that the user can drag and also rotate. Imagine a photo on a table that is at an angle to me and I want to drag it closer to me but also to rotate it so it is straight. Is there a way to use both the rotate and drag functionality at the same time with Draggable. My quick test didn't work. Thanks Anthony See the Pen MWONJmW by antdev (@antdev) on CodePen Link to comment Share on other sites More sharing options...
Solution OSUblake Posted March 10, 2022 Solution Share Posted March 10, 2022 Welcome to the forums @Antdev You can cannot combine different types of Draggables like that. There can only be 1 Draggable instance per element, so your rotation one just gets killed off. You can designate a place on your element to do rotation as shown in this thread. 1 Link to comment Share on other sites More sharing options...
Antdev Posted March 10, 2022 Author Share Posted March 10, 2022 Thank you very much for the super fast reply OSUblake. I can see why you are called a Superhero. That looks like an excellent solution that should let me make the right and left sections result in a rotation and the central section just drag. 1 Link to comment Share on other sites More sharing options...
Antdev Posted March 10, 2022 Author Share Posted March 10, 2022 I am curious what this one does? It looks like the entire card is both draggable and rotatable. See the Pen mdqNRYQ by antdev (@antdev) on CodePen Link to comment Share on other sites More sharing options...
OSUblake Posted March 10, 2022 Share Posted March 10, 2022 Yeah, that's just creating a Draggable around the containing element and the element inside of it, but as you can tell it's hard to control the rotation. The rotation is based on where the cursor is in relation to the center of the element, but when you drag on the x/y axis, your mouse doesn't say locked to the same position of the card, so it's a little funky to control. Fun, but definitely funky. 1 Link to comment Share on other sites More sharing options...
Antdev Posted March 10, 2022 Author Share Posted March 10, 2022 Thank you OSUblake - yes I agree it is a bit funky. I will stick with the other solution you recommended with the rotation elements. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now