Jump to content
Search Community

ScrollTrigger.min.js: caught TypeError: Cannot read properties of undefined (reading 'indexOf')

Paul Schlereth test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hey Team - I'm creating some GSAP parallax demos at the following url: https://livecanvas.ignitesolutions.com/smoothscroller-parallax/

 

I get the following error in Chrome devtools Console:

 

caught TypeError: Cannot read properties of undefined (reading 'indexOf')
    at A (ScrollTrigger.min.js?ver=6.2:10:566)
    at K (ScrollTrigger.min.js?ver=6.2:10:1243)
    at $.getScrollFunc (ScrollTrigger.min.js?ver=6.2:10:35446)
    at new ScrollSmoother (ScrollSmoother.min.js?ver=6.2:10:5532)
    at r.create (ScrollSmoother.min.js?ver=6.2:10:11576)
    at init-smoother-demo.js?ver=6.2:4:33
 

I looked through a few similar forum posts but am unable to resolve. Any thoughts as to what I might be doing incorrectly? -Paul

 

Link to comment
Share on other sites

  • Solution

Are you absolutely positive that the code there is being executed after the window, document and <body> are all defined? ScrollTrigger/Smoother need access to those. I bet you're running that code in the <head>, before the <body> and any of the actual elements that you're trying to animate exist. If so, the easy solutions are to either move your code to the bottom of the <body>  or just wrap it in a "DOMContentLoaded" event handler so that it waits to run until the DOM has been parsed by the browser. 

Link to comment
Share on other sites

Hi,

 

Since you're using WordPress, make sure that your code is added to the register queue after adding GSAP, ScrollTrigger and ScrollSmoother. You should make those dependencies of your custom script as discussed in this thread:

 

Hopefully this helps.

Happy Tweening!

  • Like 1
Link to comment
Share on other sites

Hey Team - that's all helpful input. I think I need to enqueue the init script (contains js plugin registration) to the footer. Jack's comment about having the DOM loaded first was a bit of a "ugh how did i not remember that" moment for me, lol. SMH. Thanks again!

 

And thanks Rodrigo, thankfully i do have the dependencies being declared.

  • Like 2
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...