Flip Plugin

Worry-free, cost-effective

migration

Arrow
Get a free migration quote
“Really great team… I’m not sure I’ve ever worked with a company that meets its deadlines in such a great way.”
Laurel Smith,
Owner at LaurelDenise.com
Flip Plugin

Animating with the Flip Plugin for GSAP

Flip plugin is one of the most advanced and  one of the most advanced plugins that lets you easily animate elements and smoothly change their position is no longer a members-only plugin! Greensock made GSAP Flip plugin free in the 3.9 release. This animation concept takes your web development experience to the next level. Flip plugin lets you seamlessly transition between two states even if there are changes to the structure of the DOM that would normally cause elements to jump. This is called layout shift, which can reduce your site score in Google or other search engines. It is surprisingly easy to code because all the heavy lifting is already done for you.

Flip plugin can give you some serious animation superpowers once you learn to think in terms of "FLIP", an acronym for "First", "Last", "Invert", "Play". Using this plugin lets you set the initial CSS (First) for an element, and the final state (Last). Flip will automatically animate the element so it can move, resize, rotate, and change however it needs. You can easily reverse this animation (Invert), or let it run similarly to a GSAP timeline (Play). Let’s dive into it!

“Flip records the current position/size/rotation of your elements, then you make whatever changes you want, and then Flip applies offsets to make them LOOK like they never moved/resized/rotated and then animates the removal of those offsets!” (Flip. Greensock. https://greensock.com/docs/v3/...)

Let’s add some magic to these cards! We are going to move these cards around just by adding a couple lines of code.

Flip screenshot

First, we have to include the gsap library.

screenshot 1

What we’ll do next – we will add a class to some of the images, let’s call it “.relocate”, and we’ll move it to “.insert” div later.

Screenshot 3

The next step will be to add javascript to our file.

Screenshot 5

Gsap also has their own utilities that can get them all for you, just like document.querySelectorAll.

Screenshot 6

Let’s import Flip plugin of 3.9 release as well.

Screenshot 7

Next we will need to set a functionality that will put all our images with class “.relocate” in “insert”. First, let’s register our plugin on the top of our script.

Screenshot 8

Step 1. Capture the state

Screenshot 9

Flip's getState method is called to collect data about the item's current size and position. This gets stored in a variable before applying other DOM edits, style changes, and so on.

Step 2. Make the changes.

After capturing the initial state data, we need to append the nodes to the ".insert” container.

Screenshot 10

Step 3. FLIP!

Screenshot 12

I added repeat with a value of “-1”, which means repeat infinitely and repeatDelay with value of “2” that will delay our animation in 2 seconds.

This example is just an introduction to what you can really achieve by adding this plugin to your project. Reading more documentation and watching tutorials will allow you to create immersive animations that can drastically change the overall experience. Read the documentation here , imagine some animation that you would like to create, use your creativity and start to play around. I hope that I gave you some inspiration, now it’s your turn.

Good luck and have fun!

Helpful resources:

Your website
is leaking sales

Join top brands who’ve improved conversions through proven, data-driven strategies.

Arrow
Get a free CRO action plan
Expert guidance.
Free Estimate.
Zero obligations.

Get expert help with CRO, website redesigns, or migrations—fast, friendly, no strings attached.

Send my action plan
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Their communication and project management. We have found great value in the way they prioritize and dig into the work in a strategic way, all while keeping us informed on what's going on and what's to come. They are incredibly organized and thorough!

L. Smith

Laurel Denise,
Owner

Their initial website creative inspired us and brought us down a new path as a brand and led us to take on a new strategy. These guys are constantly looking to improve our site and help us in any way possible

K. Pia

YumEarth,
Director of Marketing

I had the pleasure of working with the Electric Enjin team for over three years and can confidently say that they are a top-notch digital agency.

P. Beaugard

Dooney & Bourke,
Director of Ecommerce