Xenex122 Posted May 20, 2022 Share Posted May 20, 2022 So basically my animation is something like this..When the both image get the max width and height the text that is hidden as you see in the codepen. It must go down as the code says " y : 0 "...but I don't know why it isn't working but when I tried to inspect it..It is working but when you not inspect it..It will not animated to "y:0". Any idea? window.addEventListener("scroll",function e(s) { const box = document.querySelector('.box').getBoundingClientRect() if ((box.width == ((window.innerWidth/2))) && (box.height == (window.innerHeight))) { console.log("Pass In") gsap.to('.hide h3',{ y:0, ease:"none", },3) } }) See the Pen mdXwPGP by myth-vince (@myth-vince) on CodePen Link to comment Share on other sites More sharing options...
Cassie Posted May 20, 2022 Share Posted May 20, 2022 Hey there. Not sure about this approach - maybe you have your reasons and I'm not understanding, but if you're using scrollTrigger there shouldn't be any need to listen to the scroll event anymore and write custom JS logic like this. If I'm understanding the goal - maybe just use a timeline? See the Pen MWQoboQ?editors=0010 by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
Xenex122 Posted May 20, 2022 Author Share Posted May 20, 2022 @Cassie I don't see animation in your codepen ".hide h3" that it should be y:"0" it stays the same in transform: translateY(-50%)... is it animating on you? cause it is not animating on me sorry. Link to comment Share on other sites More sharing options...
GreenSock Posted May 20, 2022 Share Posted May 20, 2022 If I understand correctly, that's because you're animating "y" instead of "yPercent". 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