Jump to content
Search Community

Issue with GSAP and jQuery

Sanjero test
Moderator Tag

Recommended Posts

Hi,

 

I have a issue with using GSAP and jQuery at same time.

My GSAP code is working fine without jQuery but once I import jQuery to the index page I face the below strange behavior:

 

When I refresh the page, GSAP losing the scroll position.

 

Please open the below URL and scroll down to see the section animations, then refresh the page and try scrolling from top, you will see the issue.

 

I used the below code to prevent the browser from saving the scroll position on refreshing page, which that works for the browser but for GSAP doesn't work and GSAP losing the scroll position which is because of jQuery I think.

 

if (history.scrollRestoration) {
  history.scrollRestoration = "manual";
else {
  window.onbeforeunload = function () {
    window.scrollTo(00);
  };
}
 
I'm using:
GSAP 3.7.1
and
 
Thanks in advance.
 
 

See the Pen oNwvJKY by Sanjero (@Sanjero) on CodePen

Link to comment
Share on other sites

First of all, GSAP and ScrollTrigger have zero dependencies and I cannot imagine how loading jQuery could possibly break anything in GSAP/ScrollTrigger. They're loaded together on our site, actually :) I forked your demo and loaded jQuery and didn't see any such problems at all. I even added your code that jumps the window back to the top and never saw any problem at all. I scrolled down and hit "refresh" on the browser and it all worked perfectly from what I saw. What am I missing? Can you provide specific steps to reproduce the problem? 

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