Jump to content
Search Community

[Draggable] rotation and x,y on the same element

Achim test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

hello all,

i am trying to implement a draggable function. You should be able to move the DIVs with class "rnd" and rotate them with the rotate icon. Only if I have done rotation first, it can be moved. "move only" does not work. what could be the reason for this? I tried to solve it with a proxy (var rotateDraggable = new Draggable.create(rotation, ...), but I do not get it that the rotation is not applied to the proxy, but to the DIV.

 

 

thanks a lot for your help

Achim

See the Pen jOdMrxv by achimappel (@achimappel) on CodePen

Link to comment
Share on other sites

  • Solution

Hi @Achim and welcome to the GSAP forums!

 

Is not possible to create two different Draggable instances with the same element as the target, as soon as you create a second instance, the first one will be killed and become eligible for garbage collection.

 

The simplest thing you can do is wrap your element in order to make that wrapper the one that is moved with the x/y Draggable and add an extra element to trigger that Draggable instance or the rotation one.

 

In this simple demo the blue box is inside an element with no styles, so it's dimensions depend on the blue box. The blue box also has an extra element inside. You can rotate the box by dragging the blue box and move the blue box parent by dragging the red dot:

See the Pen LYqRyZB by GreenSock (@GreenSock) on CodePen

 

You can of course change this by adding the red dot in a corner for example, and make the red dot the one that rotates the element and the blue box moves it's parent:

See the Pen QWYKvBp by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps.

Happy Tweening!

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...