Jump to content
Search Community

Get ThrowProps end value before snap triggers

Rodrigo test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

There's a way to know the end value of the throwprops plugin before the the snap function triggers?.

 

I have an array of points for the snap function and what I want to achieve is to snap the element being dragged by one point of the array at a time no matter what, because if the speed of the throw is high enough it could advance more than one.

 

I've tried with some conditional logic onDragEnd, but snap gets called before, the only callback that triggers before is onDrag and this.endX is undefined at that time.

 

What I have achieved is using some conditional logic inside onDrag to determine whether the drag is to the left or right and based on that tell throwprops to move the element to the next or previous point, but you lose the throw ability so to speak, because the smallest drag triggers the snapp, meanwhile with throwProps if the velocity is too small the element goes back to the original position the idea is to keep that feature too.

 

I've setted up a codepen:

See the Pen hmjyA by rhernando (@rhernando) on CodePen

 

Best,

Rodrigo.

Link to comment
Share on other sites

Hi Carl,

 

Yep that comes close to what I have in mind.

 

Actually this is for a simple demo for the swipe comic book post that also can be transformed into a drag controlled slider, which would be great to promote the ThrowProps plugin.

 

Unfortunately I won't be able to sit on my computer till tomorrow afternoon, so I won't be able to check the code of the files.

 

Basically the idea is use Draggable, ThrowProps and the kinetic motion to advance one slide at a time, independent of the velocity using an array as the snap points.

 

Thanks a lot for the answer,

Rodrigo

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...