Jump to content
Search Community

Animate growing grid items

Alex.Marti test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

Hello there,

 

I'm trying to animate grid items. I have a grid with big items and small items.

 

What I try to achieve : when I click on small items, they will grow with a transition and push other items away to the next space available in the grid. The others items should also have an animation when beeing pushed away. If an item is at the end of a row, it should jump to next row with a animation.

 

What I have so far (see codepen) : I used GSAP to make items grow by changing their grid-column-end and grid-colum-row but for now there's no animation and the others items are jumping to their next position. I've also noticed a small delay when clicking on a small box, why is there this delay?

 

My question : I know it's a complexe animation/behavior to create. Before I dive deeper in this direction, I'd like to know if it's possible to achieve this with GSAP? I've seen some others posts with grid animation questions and @ZachSaucier often redirect people to use FLIP and it's helper function. Is that something that I can achieve with FLIP?

 

Thanks for your help

 

Alex

 

See the Pen poWNYJM by iamalexm (@iamalexm) on CodePen

Link to comment
Share on other sites

Hello again,

 

So I improved my grid and add a filter.

 

I took the exemple in this codependand add it to my grid. It works well. But now I'd like to add a footer or another div below my grid.

See the Pen mdPzJKp by GreenSock (@GreenSock) on CodePen

 

I have the following issue : If I put absolute : true to my Flip function, the boxes leaves and enter the way I like. But the footer jump up and down during the animation. And if I put absolute : false the footer stay in place but I lost the exit animation of the boxes. How can I have animation AND a footer that stays put?

 

Here is my codepend :

 

See the Pen poWNmyZ by iamalexm (@iamalexm) on CodePen

 

Thanks,

 

Alex

Link to comment
Share on other sites

Hi @Alex.Marti

 

The next version of Flip will include some additions that should improve this. You can specify what elements to be absolute, because you usually want to exclude the container, and there is also a setting to automatically apply absolute to elements that are leaving. 

 

Check it out. 

 

See the Pen 20ea8a7853be775238b48511a31a3386 by GreenSock (@GreenSock) on CodePen

 

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hello again @OSUblake how are you?

 

I'm having an issue with FLIP with my website. I'm using FLIP to perform a growing/shrinking effect of my grid element like the exemples above.

 

When I click on a small box to make it bigger, the other big boxes are moving smoothly from one row to another. But the small boxes are weirdly jumping between rows.

 

You can see my website here (the boxes are displayed randomly, so you may have to refresh the page to see the issue properly) : https://aureverre.abiesco.ch/pourquoi-reutiliser-le-verre/

 

My js code is exactly the same as your last codepen so I don't understand why it behaves like this.

 

Do you have any idea?

 

Thx

 

Alex

Link to comment
Share on other sites

5 minutes ago, OSUblake said:

I'm not sure. Do you think you can into a CodePen so we can play around with the code?

 

 

 

I tried but on a CodePen I was not able to repeat this behavior, it works the way I want. Maybe it's not gsap related and it's a css issue. I'll make a few tests

Link to comment
Share on other sites

1 hour ago, OSUblake said:

I'm not sure. Do you think you can into a CodePen so we can play around with the code?

 

 

 

Ok I found the issue, it was css indeed.

 

I switch my small boxes transition property from

transition: all 0.3s linear;

to

transition : transform, box-shadow 0.3s linear;

 

And it works.

Link to comment
Share on other sites

  • Solution

You keep adding animations to your master timeline, which makes it longer and longer. 

 

if(isOpen){      
   masterTL.add(flipTL.play()).add(textTL.play()).play();      
}else{
   masterTL.add(textTL.reverse(0)).add(flipTL.play()).play();
}

// keeps increasing
console.log("duration", masterTL.duration());

 

So you should skip the masterTL part and simplify it a bit like this.

 

See the Pen jOGjbgJ by GreenSock (@GreenSock) on CodePen

 

 

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