Jump to content
Search Community

GSAP Draggable, can't drag from gaps

VecchiaPrugna test
Moderator Tag

Recommended Posts

Let me explain.
I have created a slider that overflows on the right side of the screen, a design choice you often see in lots of websites.

What I want you to notice is that you can drag by grabbing (on desktop device) or swiping (on touch device) starting the motion from within the slide but also within the gaps. However, if you try dragging from within the gaps of the last slides (the ones that initially overflow) it does not work.

I hope that was clear, english is not my main language.

Any idea how to solve this?

See the Pen QWoezvm by ykvdnykw-the-bold (@ykvdnykw-the-bold) on CodePen

Link to comment
Share on other sites

It would work if your .slider element was as big as it was. I don't have time to dive into it right now, but with some CSS you would be able to make the .slider element take up all the space it needs and not only in the .slider-wrapper.

 

To recap you can drag everything that is orange in the element below, because this is the width of your .slider element and instead the orange should be behind all the pink elements, not just what is inside the .slider-wrapper. Hope it helps and happy tweening! 

 

See the Pen MWRopoj by mvaneijgen (@mvaneijgen) on CodePen

Link to comment
Share on other sites

Hi,

 

Just with CSS I'm not aware, but I'm far from being a CSS wiki so take my word with a giant grain of salt since most likely is possible, I'm just ignorant on the fact. But with GSAP is super easy though:

gsap.set(slider, {
  width: slider.scrollWidth,
});

Here is a demo:

See the Pen bGJpOoQ by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps.

Happy Tweening!

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...