Jump to content
GreenSock

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

svg inside svg + To() = doesn't work on Chrome

Recommended Posts

Hi,

 

This simple example doesn't work with Chrome , but work with Firefox.

 

Do you know the reason ?

 

Chrome : Version 75.0.3770.80 (Build officiel) (64 bits)

Firefox : 67.0.2 

 

Thanks you

See the Pen BgNbpj by jackisjack-the-bold (@jackisjack-the-bold) on CodePen

Link to comment
Share on other sites

Hello @JackIsJack44 and welcome to the GreenSock Forum!

 

That doesn't work in Chrome due to the nesting of SVG element within another SVG element.
 

You have to target your main parent <svg> #main and not its child nested <svg> #test.

 

var t1 = new TimelineMax();
  
t1.to('#main', 2, {x:200,y:200});

 

See the Pen agOrBJ by jonathan (@jonathan) on CodePen

 

Happy Tweening :)

  • Like 3
Link to comment
Share on other sites

Thanks you but I can't move the main svg (Sorry I didn't explain the whole situation...:))

 

1/ I am using a global svg as a main container because it has a viewbox property that enables me to make zoom/focus easily.

2/ and I use as many svg child as elements because I want to be able to know their positions and width/height easily.

 

Is there a better way to do that  ? 

 

See the Pen BgozYz by jackisjack-the-bold (@jackisjack-the-bold) on CodePen

Link to comment
Share on other sites

Maybe I'm not understanding this project, but why does each child need to a be a new SVG? Couldn't they just be groups of elements?

  • Like 1
Link to comment
Share on other sites

Good question. That's because I didn't find a proper way to get the 'height/width' of a <g> element.

Link to comment
Share on other sites

If you just need all the original sizes and positions before transforms, getBBox() should work fine. After transforms have been applied is a different story. Blake has a good write-up here:

 Happy tweening.

  • Like 1
Link to comment
Share on other sites

Great link. Thanks you. I have to think now...

native getBBox() vs specific getBBox() vs getBoundingClientRect() vs nested svg (but gsap+chrome KO) vs <g>+<use> ...

 

 

 

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