Site icon Denis Bouquet

gsap ScrollTrigger Uncaught TypeError: _toArray is not a function

I struggled a bit with the ScrollTrigger import in a new project. I could log ScrollTrigger, but it was not working. Using the CDN imports, it was all good. If you have this error, it’s likely the import is wrong.

How to fix gsap ScrollTrigger Uncaught TypeError: _toArray is not a function

I was using

gsap.registerPlugin('ScrollTrigger');

instead of:

gsap.registerPlugin(ScrollTrigger);

To debug ScrollTrigger you can first check the version you use

console.log(ScrollTrigger.version)

The import should look like.

import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
gsap.registerPlugin(ScrollTrigger);

If this small post saved you time debugging your ScrollTrigger, share a thumbs up!

Exit mobile version