Jump to content
Search Community

How to integrate a cookie to my GSAP code JS

kri2sis 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 got a animation as a preloader of images and css files. 

But it run each time I open a new page or reload the same page.

 

I think I have to use a cookie method because images are load one time in the cache and no need to run another time the animation.

 

I'm not a friend of cookie so i got trouble with this method.

I can find script on the web but how can I integrate it to apply it to my animation ?

 

Please.

 

Thx for your help.

Link to comment
Share on other sites

I'm not really sure how your preloader or animation is setup, but is there something preventing you from skipping the animation to the end once the preloader reports everything has loaded? e.g. if your animation is on a timeline, just skip to the end with mytimeline.progress(1). Also I'm not convinced a cookie would be the right way to go about this either; the cache could be cleared/invalidated while the cookie exists and then your preloader animation wouldn't show up.

 

Unfortunately we don't usually offer assistance with general javascript questions about stuff like preloaders and cookies here, as we need to focus our time on supporting GSAP itself.

  • Like 2
Link to comment
Share on other sites

Hello kri2sis,

 

You could take a look at using jquery-cookie: https://github.com/carhartl/jquery-cookie

 

References:

http://stackoverflow.com/questions/14573223/set-cookie-and-get-cookie-with-javascript

https://developer.mozilla.org/en-US/docs/Web/API/document.cookie

 

Also using HTML5 local storage in the browser:

 

https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage

See the Pen Hlfma by awesom3 (@awesom3) on CodePen

http://codebase.es/test/webstorage.html

 

Once you get familar with cookies or local storage than it will be easy to integrate with GSAP hope this helps!

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...