Jump to content
Search Community

Using SmoothScroll on a WordPress theme

Fábio Melo test
Moderator Tag

Go to solution Solved by Fábio Melo,

Recommended Posts

Hello,

 

So, I'm using WordPress with a purchased theme, and they do use GSAP 3.6.1. When I try to import ScrollSmoother, it throws an error:


Uncaught TypeError: Cannot read properties of undefined (reading '_getVelocityProp')


Which, from my research, means version mismatch. I tried editing the theme files to remove the old GSAP version and put the most recent one, but other errors appear, making it really hard to make it work (Also, by removing the old GSAP code from the theme, the ScrollSmoother did work, hence I know is a version mismatch problem).

 

cdnzgmk.png

 

As shown in the print, the ScrollSmoother is not using GSAP from the CDN, is using the theme file "plugins.js". Is there any way you guys know of where I can keep the theme files untouched and "force" the ScrollSmoother to function with the newest version of GSAP (let the theme use their own, and I import the most recent one)?

 

If thats not possible, is there anywhere I can get the "ShockinglyGreen" suit of scripts on version 3.6.1 (I only found GSAP 2 Archive for download) so that I can work on this project without further problems from the theme?

 

Thanks in advance

Link to comment
Share on other sites

Editing the original theme's files, is never a good idea, as you'd face several issues on future updates.

 

Depending on how the theme loads the scripts, you could add your own hook in yourfunctions.php , dequeue the ones you don't want and enqueue the gsap version you want, along with any other plugins you need. 

 

However keep in mind that since this file is called plugins.js, i'm guessing that it may include other libraries as well. So dequeuing that file, might break other functionalities as well. 

 

I think the safest bet would be to reach out to the theme's authors and simply ask to update to the latest version.

  • Like 3
Link to comment
Share on other sites

34 minutes ago, Yannis Yannakopoulos said:

Depending on how the theme loads the scripts, you could add your own hook in yourfunctions.php , dequeue the ones you don't want and enqueue the gsap version you want, along with any other plugins you need. 

 

However keep in mind that since this file is called plugins.js, i'm guessing that it may include other libraries as well. So dequeuing that file, might break other functionalities as well. 

 

True, that is exactly what happened. Thats where the new errors came from.

 

Quote

I think the safest bet would be to reach out to the theme's authors and simply ask to update to the latest version.


I did not think of that. Will do it, the only problem is the time it will take them. They probably won't do it right away. I saw on a different post the user "ZachSaucier" saying he could provide old versions of the scripts. Was hoping someone from GSAP was kind enought to provide them as a short term solution for me 😄

Link to comment
Share on other sites

We most certainly can provide old versions, but ScrollSmoother was added in version 3.10 so I don't think that will help you here. 🙃
 

1 hour ago, Fábio Melo said:

True, that is exactly what happened. Thats where the new errors came from.

This sounds like you nailed down the issue though, are you sorted? 

  • Like 1
Link to comment
Share on other sites

  • Solution
25 minutes ago, Cassie said:

We most certainly can provide old versions, but ScrollSmoother was added in version 3.10 so I don't think that will help you here. 🙃
 

This sounds like you nailed down the issue though, are you sorted? 

 

Well, actually, I think so.

 

After reading your post I gave another look to the theme file, which had GSAP 3.6.1 and ScrollTrigger 3.8.0 a couple thousand lines below (this one was actually the culprit of the errors, and I didn't see it before). Changed the code from both with the versions 3.11.3, queued the ScrollSmoother 3.11.3, and so far console is clear of errors, with a smooth scroll.

 

Now, like @Yannis Yannakopoulos said above, I will run into problems with a theme update, but for now it seems to be all good.

 

Thank you all for the help 😄

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