Jump to content
Search Community

How to access matrix in transform attribute svg/Raphael?

pbohny 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

this is my element I want to access

<rect x="0" y="0" width="896" height="504" r="0" rx="0" ry="0" fill="#55edff" stroke="#eeffdd" 
opacity="1.0" stroke-width="25" stroke-opacity="1.0" fill-opacity="1.0" 
vector-effect="non-scaling-stroke" transform="matrix(0.1,0,0,0.2,403.2,201.6)">
</rect>

acccessing e.g. the opacity works great:

TweenMax.to(rectangle, 5, {raphael:{'opacity':0.2}, ease:Elastic.easeOut});

 
but how would I access the values in the transform attribute?

transform="matrix(0.1,0,0,0.2,403.2,201.6)"
Link to comment
Share on other sites

I think I figured something out, please could somebody confirm, that my assumptions are correct? 

You don't manipulate the matrix directly, its just a representation of calcualted values. You use standard commands like e.g.

 

 {raphael:{'scaleX':0.5}

This controls scaling, with 'rotation'  I control rotation and with x and y the translate.x and y values.

 

But why are the pixel values a 10-fold of the real value, meaning it's

 

{raphael:{'x':3000}

 

 to move 300px?

Link to comment
Share on other sites

Yes, the matrix is just a combination of various individual values like scaleX, scaleY, x, y, rotation, etc. You can just tween those. As far as why it's ten-fold, it shouldn't be - I wonder if you've got a parent container that's at 1/10th scale, thus for every pixel you move its child, it only looks like 1/10th of a pixel. See what I mean? Feel free to post a very simple example/codepen/jsfiddle that clearly demonstrates the issue if you're still having trouble. 

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