Jump to content
Search Community

Animate only once

Nexal 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, i want to animate with TweenMax only once. it is possible to do it? the animation should be triggered only the first time that the user open the page. so if the user go into other page and then he came back the animation doesn't have to trigger.

 

 

Can I only use the sessions to do it or do some other methods exist?

See the Pen WqqZwW by damiano31 (@damiano31) on CodePen

Link to comment
Share on other sites

Hello Nexal and welcome.

 

As SARFEX commented, this can be done using cookies or localstorage (I'd not recommend using IndexedDB for something this simple). I'd search for something like "js tell if user has visited page before" to find more information about how to do so. 

 

Basic approach: 

  • Check to see if a specific cookie or localstorage exists.
    • If it does, don't animate.
    • If it doesn't exist, animate whatever you want to animate and create the cookie/localstorage that you're looking for.

Let us know if you run into any issues, especially related to the GSAP part of your code!

  • Like 4
  • Thanks 1
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...