MaxiBartolozzi Posted March 28, 2020 Share Posted March 28, 2020 Hi guys, This is my first time working with gsap and I'm running into an issue with my slider. I've created this slider, now it's starting on <div class="first"> on the left. What I'd like to do is to center the slider on <div class="third"> on render. I'd appreciate your help See the Pen yLNGRzP by mxbarto (@mxbarto) on CodePen Link to comment Share on other sites More sharing options...
ZachSaucier Posted March 28, 2020 Share Posted March 28, 2020 Hey Maxi and welcome to the GreenSock forums! Thanks for being a Club GreenSock member. There's a couple aspects of your approach that don't make much sense to me: Your container element is scrollable. That completely ignores the draggable's effect, they don't play nicely with each other by default. I recommend preventing scrolling on your container. You have an element called draggable but you apply the actual Draggable to the container... I'd apply the Draggable to the element called draggable. You set the bounds to an element within the Draggable. The bounding element is presumed to be an element outside of the Draggable. To set the default position of the draggle element, just set the x of it. Here's how I'd set it up. I included two different potential start positions because you weren't clear on the exact effect that you want. See the Pen poJqqKy?editors=0010 by GreenSock (@GreenSock) on CodePen For an even better effect, add in GSAP's IntertiaPlugin! See the Pen OJVrrEY?editors=0010 by GreenSock (@GreenSock) on CodePen 3 Link to comment Share on other sites More sharing options...
MaxiBartolozzi Posted March 28, 2020 Author Share Posted March 28, 2020 Hi Zach, Seems like I have to get deeper into the gsap documentation before trying making this 😑. The second one is the one that I was looking for. Thanks very much for your help! I really appreciate it. 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