Jump to content
Search Community

tweening raphael js objects

gareth test
Moderator Tag

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

It looks like that's just how Raphael works - try removing GSAP from the equation altogether and you'll see that if you try to set the circle's x or y or tx or ty, it has no effect whatsoever, like:

//has no effect:
circle.attr({x:100}); 
circle.attr({tx:100});

However, you can move where the center of the circle starts by using the "cx" and "cy" properties:

//works:
circle.attr({cx:100, cy:100});

Which also means you can tween them:

TweenLite.to(circle, 2, {raphael:{cx:100, cy:100}});

Disclaimer: we're not Raphael experts and if you have questions that are specific to that framework, you should probably contact the author(s). 

  • Like 1
Link to comment
Share on other sites

That's more of a Raphael-specific question (unfortunately I just don't have time to chase that down for you and devise the best approach in Raphael right now). At the very least, you could certainly tween some properties of a generic object and then use an onUpdate to feed those into your arc() or circularArc() methods. 

Link to comment
Share on other sites

If you're doing something relatively simple (like circles and arcs on Canvas), you might just want to skip Raphael altogether and do it by scratch.  I had to create a pie chart recently where the user would cause a 'slice' of the pie to appear by dragging (using GSAP's own Draggable of course), which involved some updating of the arc on the fly. 

 

I had to find a tutorial to help me construct the pie chart in the first place, before building in the rest.  Here is the one I used, and you could certainly use TweenMax to create it over time: 

 

http://wickedlysmart.com/how-to-make-a-pie-chart-with-html5s-canvas/

 

Maybe it might help you out... :) 

Link to comment
Share on other sites

Hi Gareth

 

The tweens were not working because the code was outside the function

 

Before (not working):

});

// tween arc with tweenmax (nothing get's tweened)
TweenMax.to(arc, 80, {raphael:{'stroke-width':60, width:20, height:50, stroke:"#0000ff", scaleX:2}});

After (working):

// tween arc with tweenmax (nothing get's tweened)
TweenMax.to(arc, 80, {raphael:{'stroke-width':60, width:20, height:50, stroke:"#0000ff", scaleX:2}});
});

Hope this helps!

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