Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Nexal

Animate only once

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

Share this post


Link to post
Share on other sites

You can use cookies! 🍪🍪🍪

or localstorage // or IndexedDB maybe

  • Like 2
  • Haha 1

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×