Jump to content
GreenSock

bigbeats01

IE SVG transforms

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

I know in IE, you cannot transform svg child elements normally with the style attribute so you need to fallback to updating the transform attribute on the element within the svg.

TweenMax.to('#circle', 1, {scaleX : 1, onUpdate: scaleXie, onUpdateParams: ["{self}"]});

function scaleXie(t){			
  if(!Modernizr.smil){
  //fallback for IE.
     $(t.target.selector).attr('transform', 'matrix(' + t.target[0]._gsTransform.scaleX + ', 0, 0, 1, 0,0)');
  }
}

This works but is there a more elegant / global way to have TweenMax update the transform attribute on svg elements when the browser is IE ?  I have many of these transform tweens and would like to know if there is a better way at polyfilling IE.  

Link to comment
Share on other sites

Sorry, GSAP does not do anything special behind the scenes to handle SVG tweens in any version of IE.

Link to comment
Share on other sites

I know this is just my two cents .. but what about wrapping your SVG parent element in a div and animate the div instead? .. or is my two cents worth no cents :unsure:

Link to comment
Share on other sites

Jonathan, I'll give you 3 cents for you 2 cents any day!

  • Like 3
Link to comment
Share on other sites

Thanks but I'm animating an element within an svg, not the entire svg

Link to comment
Share on other sites

Just adding to what you already have bigbeats01 using the jQuery attr() method. You could opt to use GSAP set() method instead, so GSAP can keep track of what values your setting:

TweenMax.to('#circle', 1, {scaleX : 1, onUpdate: scaleXie, onUpdateParams: ["{self}"]});

function scaleXie(t){			
  if(!Modernizr.smil){
     //fallback for IE.
     TweenMax.set($(t.target.selector), {'transform', 'matrix(' + t.target[0]._gsTransform.scaleX + ', 0, 0, 1, 0,0)'});
  }
}

By using set() you are allowing GSAP to write and store the values, so if there is any changes outside of GSAP, it knows what you have changed.

 

:)

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