Flip Plugin
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:

selected projects
selected projects
selected projects
Big ideas. Bigger results. Let’s make it happen. Get an instant quote today.

sf-required

Manage recurring validation states.
sf-form_input
sf-required
Field Input (Required)
sf-form_checkbox-field
sf-required
Checkbox (Required)
sf-form_radio-field
sf-required
Radio (Required)
sf-form_input-select
sf-required
Select (Required)
sf-form_input-date
is-icon-left-right
sf-required
sf-form-icon-left
sf-required
Date Input (Required)
This is an error tag
sf-form_input-error-wrapper
sf-required
Error Tag (Required)
sf-form-icon-right
sf-required
Icon on Input Right (Required)
sf-form-icon-left
sf-required
Icon on Input Left (Required)
sf-form-icon-right
is-text-area
sf-required
Icon on Input Right Text Area (Required)

sf-checked

Manage recurring checked radio & checkboxes states.
sf-form_checkbox-field
sf-checked
Checkbox (Checked)
sf-form_radio-field
sf-checked
Radio (Checked)

sf-focus

Manage recurring focusing for button, radio and checkbox states.
sf-form_radio-field
sf-focus
Radio (Focused)
sf-form_checkbox-field
sf-focus
Checkbox (Focused)

sf-hide

Manage hidden states.
sf-skeleton
sf-hide
Loader Box (Currently Hidden)

sf-await

Manage awaiting states.
sf-button-child
sf-await
sf-button-await-child
sf-await
Awaiting Status of Buttons
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Step {Current Slide}/{Max Slides}

Project Details

Start by telling us about your project.
This field is empty
Enter a valid email
Select one option
Next Slide

Key Project Requirements

Tell us about the essential features and requirements for your project.
This field is empty
Select one option
Next Slide

Timeline & Budget

Tell us about your project's timeline and budget.
This field is empty
Select one option
Next Slide

Additional Information

Anything else you'd like to add?
This field is empty
Select one option
End
Thank you! Your submission has been received! A representative will be in touch within 24 hours.
Oops! Something went wrong while submitting the form.