kohlej Posted April 29, 2021 Share Posted April 29, 2021 Hi guys, here is simple demo of me using scrollWidth of element - clientWidth to show whole .roller__inner on scroll. However it's not showing the right padding of .roller__inner as it should. (As far as I know scrollWidth takes padding into the value) Anyone can help with this? See the Pen mdRYmpO?editors=0010 by kohlej (@kohlej) on CodePen Link to comment Share on other sites More sharing options...
akapowl Posted April 29, 2021 Share Posted April 29, 2021 Hey @kohlej I'm pretty sure, ScrollTrigger is interpreting things correctly there. Your problem is more CSS-layout related. You can see that when you comment out all your JS and remove the overflow-x: hidden from your roller, that things are not set up the way you might think in the first place. So you might want to tweek your setup so it displays as wanted first before hooking it up to ScrollTrigger. See the Pen cd0294f560181f28090532d7ea106fdd by akapowl (@akapowl) on CodePen 1 Link to comment Share on other sites More sharing options...
kohlej Posted April 29, 2021 Author Share Posted April 29, 2021 6 minutes ago, akapowl said: Hey @kohlej I'm pretty sure, ScrollTrigger is interpreting things correctly there. Your problem is more CSS-layout related. You can see that when you comment out all your JS and remove the overflow-x: hidden from your roller, that things are not set up the way you might think in the first place. So you might want to tweek your setup so it displays as wanted first before hooking it up to ScrollTrigger. I thought that might be the case, but then it weirded me out that it actually almost does the right thing. I know that .roller__inner isnt taking the width of child elements, but of my viewport width, but why does it even scroll then? I will look into it and update here 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