Dennyno Posted November 10, 2021 Share Posted November 10, 2021 Hi guys. I was trying to update an old tweenmax script See the Pen zxYJZP by johnstew (@johnstew) on CodePen to GSAP 3, but I'm entering strange errors. Any sweet help on this task please? The syntax seems legit.. just cant make it works. Seems that a var is missing.. but it's the same code taken from the previous codepen. Thanks all See the Pen NWvBNXV by DedaloD (@DedaloD) on CodePen Link to comment Share on other sites More sharing options...
PointC Posted November 10, 2021 Share Posted November 10, 2021 I'm not sure why but the new version shows 4 children so the overlay div is actually: var overlay = this.childNodes[2]; Or you can use querySelector like this. See the Pen ef06524aa4b632d89a062d488d0a0388 by PointC (@PointC) on CodePen Happy tweening. 1 Link to comment Share on other sites More sharing options...
PointC Posted November 10, 2021 Share Posted November 10, 2021 Or children will work too since that will only be element nodes. https://developer.mozilla.org/en-US/docs/Web/API/Element/children 2 Link to comment Share on other sites More sharing options...
Dennyno Posted November 10, 2021 Author Share Posted November 10, 2021 EDIT: (Im drunk. I'vd read jQuery instead of queryselector) - sorry 😛 Thanks, this is strage btw... isn'it? I'm trying to avoid jQuery Link to comment Share on other sites More sharing options...
Solution PointC Posted November 10, 2021 Solution Share Posted November 10, 2021 It took me a minute to see what was happening because the original TweenMax version was only showing 2 child nodes and the new GSAP3 version was showing 4 child nodes. Looking further I see the HTML in the original demo is all minified whereas the new version is all formatted and pretty so it's picking up the space as a text node I guess. If you use CodePen's "format HTML" feature on the original version, it will break too. Best to use children or querySelector. Happy tweening. 3 Link to comment Share on other sites More sharing options...
Dennyno Posted November 10, 2021 Author Share Posted November 10, 2021 So clear, so inspiring. Thanks 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now