Jump to content
Search Community

tweenmax and screen orientation

spica2 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

I am using some fromto css animations. gsap writes the css as inline styles, eg relative margin informations to absolute pixel margins. when I change the windowsize or change the orientation on a smart device my design is broken, because the absolute pixels do not fit to the new window dimension.

 

Is there a general concept to deal with that?

Link to comment
Share on other sites

Thanks. That helped. A bit :-)

 

It deals responive positioning with gsap. But still the problem, what if the script is already running with its calculated measuments and a new mediaquery gets in action (e.g. device rotation) with other styles, e.g. you want to switch from a centered to left aligned.

Link to comment
Share on other sites

if i understood correctly and you want to re set a tween's property ,  you need .invalidate() ( same usage for tweens and Timelines )

 

pls check this Codepen Demo : 

See the Pen bddvgy by MAW (@MAW) on CodePen

 

var Tween = TweenMax.to(".red",2,{x:100});

var tl = new TimelineMax({repeat:-1});
tl.add(Tween)
  .to(".blue",2,{x:100});

$("#change").on("click", function() {
  Tween.vars.css.x = 500;
  tl.seek(0).invalidate().restart();})

 

otherwise ,  i think that's better to provide a reduced Codepen Demo 

});

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