Ves Posted June 15, 2022 Share Posted June 15, 2022 Hello there! I'm open to any suggestions, how to improve this list animation. I'm trying to create list animation. When we scroll to .target section, scroll stops, and then next animation starting. All good so far. But the list animation is not correct. It's should be visible 3 items in a time, and the middle one is highlighted. But i've got some bugs with it. I will be grateful for any help. See the Pen YzeBmpK by vasya-ves (@vasya-ves) on CodePen Link to comment Share on other sites More sharing options...
Ves Posted June 15, 2022 Author Share Posted June 15, 2022 That's what i'm trying to achieve Screen Recording 2022-06-15 at 22.26.06.mov Link to comment Share on other sites More sharing options...
Solution PointC Posted June 15, 2022 Solution Share Posted June 15, 2022 Hi @Ves Welcome to the forum. I think I'd wire this up a bit differently. I'd create a timeline and scrub through it rather than add individual triggers to each element. Something like this. See the Pen BaYbaNb by PointC (@PointC) on CodePen Hopefully that helps. Happy tweening and welcome aboard. 2 Link to comment Share on other sites More sharing options...
Ves Posted June 16, 2022 Author Share Posted June 16, 2022 Hi, @PointC ! Your solution is much easier and works like a charm! Thank you so much! Maybe you have time to clarify 2 things, i don't quiet understand in your code. Why you disable warnings in tis line gsap.config({ trialWarn: false }); And this line, why multiple by 3? let newHeight = targets[0].offsetHeight * 3; Link to comment Share on other sites More sharing options...
Ves Posted June 16, 2022 Author Share Posted June 16, 2022 We multiply by 3, because we want to show 3 items in a time. Sorry for not thinking Link to comment Share on other sites More sharing options...
PointC Posted June 16, 2022 Share Posted June 16, 2022 11 hours ago, Ves said: We multiply by 3, because we want to show 3 items in a time. Exactly. You wouldn't need to do it with JS. You could also just set a height for the <li> elements and manually set a height for the <ul> in your CSS. The trialWarn:false thing is just for CodePen so you don't see any warnings in the console. Nothing at all to do with the animations. Happy tweening. 2 Link to comment Share on other sites More sharing options...
Ves Posted June 17, 2022 Author Share Posted June 17, 2022 @PointC thank you so much for clarification and your help! 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