Jump to content
Search Community

getting a button to rotate an object

Darkin test
Moderator Tag

Go to solution Solved by Carl,

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

Hey guys i'm new to GSAP,

so pardon the "DUH" noob question.

 

I'm trying to rotate an object by pressing a button.

so far i have the object to rotate on LOAD

but when i press the button- nothing happens.

I can MOVE the object if I want on button press but i can't figure out why the object will not rotate on button press.

 

I have a link to code pen.

I am also new to code pen, so apologies in advance if some thing is missing. I posted it to the best of my ability.

Thanks guys.

 

See the Pen XJJXpg?editors=110 by anon (@anon) on CodePen

Link to comment
Share on other sites

  • Solution

Hi Darkin,

 

Welcome to the GreenSock forums.

Appreciate you creating the demo.

 

I forked Maelfyn's demo to show 2 more options.

 

His startAt is fine, but you can also use a TweenLite.fromTo() or TweenMax.fromTo() (both are the same)

//spin from 0 to 360
TweenMax.fromTo('#test', 1, {rotation:0}, {rotation:360})
or you can do a relative tween by placing the values in quotes with += or -=
//spin 360 more than current rotation
TweenMax.to('#test', 1, {rotation:"+=360"})

Demo: http://codepen.io/GreenSock/pen/dPPGeQ?editors=101

 

As for how to use CodePen, notice that we are both loading in the TweenMax files using the gear in the JS panel.

Also you can write your js code in the JS panel. CodePen automatically executes that code after the DOM is ready so you don't have to wrap it in a jQuery ready() or anything like that. Give this a video a quick look, as it covers most of the basics: http://greensock.com/forums/topic/9002-read-this-first-how-to-create-a-codepen-demo/

 

Let us know if you have any more questions.

 

Carl

 

ps. Nice job, Maelfyn. Great to have you as part of the community.

 

 

  • Like 1
Link to comment
Share on other sites

  • 6 months later...

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...