Jump to content


Draggable: how to set rotation via code?

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

When I create a Draggable object of type "rotation", it starts at 0 degrees rotation. Is there a way to set this to another value via JavaScript code?


Use case: I've got a dial that selects a particular setting that gets saved. When the user comes back to the screen I want the dial to be positioned to the previous setting.





Link to comment
Share on other sites


//create Draggable
Draggable.create("#yourID", {type:"rotation"});

//get the Draggable instance (you could also combine this with the line above like var yourDraggable = Draggable.create(...)[0]
var yourDraggable = Draggable.get("#yourID");

//set the rotation to whatever you want.
TweenLite.set("#yourID", {rotation:45});

//tell the Draggable to calibrate/synchronize/read the current value
  • Like 3
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.