Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
gareth

tweening raphael js objects

Recommended Posts

Hi,

 

I am trying to use the raphael plugin, but without much luck:

 

See the Pen DJzah by eighthday (@eighthday) on CodePen

 

Circle - only gets it fill tweened

Arc - unable to tween anything

 

are these things not possible?

 

 

Link to comment
Share on other sites

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

Ok, thanks - btw the tweenmax docs gave me the properties.

I want to be able to tween the length of an arc, is there a better way to do it with tween max?

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

Understood, I appreciate you are very busy.

 

I actually meant is there a better way than using Rapheal?

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