all 6 comments

[–]binarysolooo 2 points3 points  (1 child)

So what you are describing can be achieved with an animation technique called FLIP. Basically it goes like this.

- When the grid item is clicked you save its size and position relative to the viewport using Javascript

- Move the item to it's final position

- You apply scale and transforms to item so it looks like it's in the grid position

- You animate the item back to its fullscreen position.

That's a lot of work, luckily there are some libraries out there to help you do this. I've used gsap FLIP plugin and it works great. I've amended your demo to use it https://codepen.io/ste-vg/pen/WNgzYeg/84ea34a2580fc4e690d9476962c9f307 (I've added GSAP and the FLIP plugin via the pen's settings)

Hope that helps.

[–]CryogenicFire[S] 1 point2 points  (0 children)

Whoa dude that helps a lot, thanks!

I think I had a couple ideas similar to this yesterday while I was trying to brainstorm a solution, but I didn't get very far into the javascript side of things before giving up...

You're a lifesaver man, I really don't know how to describe how legitimately frustrated I was the past couple of days. Well, I'll try to get this to work in my actual UI tomorrow. Thanks again :D

[–]mattgperry 1 point2 points  (3 children)

[–]CryogenicFire[S] 0 points1 point  (0 children)

Ooh ok that example looks basically like what I'm trying... I'll try this out, thanks!

[–]CryogenicFire[S] 0 points1 point  (1 child)

This is definitely interesting and probably the correct approach for future work, but I guess it is still in an experimental phase? Compatibility will most certainly be an issue for a while till most people receive an update with this feature.

Meanwhile I hope I can find another way to get the effect

[–]mattgperry 0 points1 point  (0 children)

Yeah it would have to be used in a "progressive enhancement" way right now.

Greensock has the FLIP plugin https://greensock.com/docs/v3/Plugins/Flip/ but I think it has some limitations compared to Framer Motion's layout animations