Jump to content
GreenSock

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

ios bug on rotation

Recommended Posts

I forked this off of codepen. 

See the Pen OyQeQv by magalhaespaulo (@magalhaespaulo) on CodePen

But mine does not render correctly on iOS. The road and clouds rotate correctly, but the city is way off on iOS. I am trying to get it to work so I can use it on a banner ad.

See the Pen pRxVRO by shawnalee (@shawnalee) on CodePen

Link to comment
Share on other sites

Hello shawnalee, and Welcome to the GreenSock Forums

 

I'm not near my computer right now, but what if you change your rotation for your city tween:

 

From this -360:

TweenMax.to('#city', 30, {rotation:-360, transformOrigin: '53.3% 54.7%', ease:Linear.easeNone, repeat:-1});

to this using a relative tween "-=360_cw":

TweenMax.to('#city', 30, {rotation:"-=360_cw", transformOrigin: '53.3% 54.7%', ease:Linear.easeNone, repeat:-1});

See CSSPlugin Docs:

 

https://greensock.com/docs/#/HTML5/GSAP/Plugins/CSSPlugin/

 

Under directionalRotation

 

See if that works for you :)

Link to comment
Share on other sites

post-51039-0-77017600-1487962072_thumb.png

 

Thank you so much for the response. I tried that and it is still broken on ipad/iphone, etc. 

Link to comment
Share on other sites

Looks like Carl may be working on answer, but I'll sneak in here quickly. Have you tried using svgOrigin instead of transformOrigin on your group? Please give this a try on your city group:

TweenMax.to('#city', 30, {rotation:"-=360_cw", svgOrigin: '188.78 188.96', ease:Linear.easeNone, repeat:-1});

Hopefully that helps.

 

Happy tweening.

:)

  • Like 3
Link to comment
Share on other sites

Interesting - the problem boils down to something you can see with one line of code in your example:

console.log(document.querySelector("#city").getBBox());
//Safari: {x: -0.8500000238418579, y: 0, width: 319.9736328125, height: 335.6852111816406}
//Other browsers: {x: 42.81999969482422, y: 50.01018524169922, width: 276.7608337402344, height: 286.3160705566406}

As you can see, that's not related to GSAP at all. Pretty annoying, I know. I think it has to do with the way Safari is handling the transforms in your elements (I noticed you've got a transform applied to almost everything), like it's including those when it calculates the bounding box. 

 

Craig's solution with svgOrigin seems like the best, easiest solution here. I don't see a good way for GSAP to somehow work around this Safari issue without having to literally loop through every child and remove its transforms, do the measurement, and then add them back (CPU-intensive, and the code would bloat CSSPlugin). Hopefully Safari will get this fixed soon. 

  • Like 3
Link to comment
Share on other sites

I have a question. How do you even get a transform in your markup? I've used all sorts of vector editing software, and I have never seen a transform in the output. I would expect most software to apply transforms to the object and its children, and not store it as a transform.

Link to comment
Share on other sites

That worked! I used Illustrator to save the vector as a SVG.  I had to manually group the items I wanted to rotate in the code. I will have to keep that in mind next time I export. Thanks everyone!

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