I’m trying to add this slide animation to my project but the console keeps saying “gsap is not defined”.
please have a look. Your contribution is a lot appreciated.
Thanks
The link is not to your project
When I opend your code pen nothing is in it
What i ussualy do is simply Google the defenition of what the error means in this case it tells me 2 things:
The ReferenceError object represents an error when a non-existent variable is referenced.8 mei 2020
Reference Error : JavaScript. … When any value is assigned to undeclared variable or assignment without the var keyword or variable is not in your current scope, it might lead to unexpected results and that’s why JavaScript presents a ReferenceError : assignment to undeclared variable “x” in strict mode
However when i look at your code i notice the next line
gsap.to(socialMediaAdvert, 1 , { x : "100%"});
But where did you import gsap module?
From ‘scrollmagic cdn’ on google.
That’s great it’s a good thing to try new modules but, code pen doesn’t know it’s there. Maybe you could try to use import it? so code pen might be able to find it and make the function work?
The animation.gsap.js
plug-in depends on the GSAP library.
https://cdnjs.cloudflare.com/ajax/libs/gsap/3.2.6/gsap.min.js
Did that before but it was giving me an error message so I removed it. I’ve added it back now. You can check it now.
Still not working
I will try that now. Thanks
You are using greensock directly (gsap.to()
) so you need it, and as you can see the error you had goes away when adding it.
socialmedia-advert
is an empty div, you wouldn’t see anything if it did work.