Jump to content
Search Community

Responsive animation using fixed values

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

Hi all,

I'm new to GSAP forums, so I hope somebody can help.

 

I've created something that mimics the functionality of CSS media queries within javascript, however, as Greensock uses inline styles, you'd need to remove the style attribute once the animation has completed.

 

My question - Is there any built-in functionality within GSAP where you can define breakpoints without using a multiple if/else conditionals?

I've attached a codepen of my current solution which you will see on the lines, either side of the tagline.

See the Pen zdNMNW by carljohnston-uk (@carljohnston-uk) on CodePen

Edited by carljohnston.uk
Codepen explanation clarification
Link to comment
Share on other sites

Hi @carljohnston.uk,

 

Welcome to GreenSock Forums.

 

Simply said no: GreenSock is animation library not an all-round tool.

 

But you will find some post regarding CSS media queries in this Forum. For example this one:

https://greensock.com/forums/topic/11172-using-media-queries-in-tweenmax

 

On 16.1.2015 at 6:52 AM, OSUblake said:

Here's another tip. You can add listeners to your media queries instead of doing a window resize event to find a match. Adding listeners will allow you to create a dynamic list of queries for things like height, width, orientation, handheld, aspect, etc. 

 

Here's a scaled down version of what I use. You can see the dynamic queries in action when you click the remove button on the large media div.

 

See the Pen vExQEy by osublake (@osublake) on CodePen

 

Kind regards

Mikel

  • Like 3
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...