Jump to content


Get ThrowProps end value before snap triggers

Recommended Posts



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




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,


Link to comment
Share on other sites

Pretty good!!


I'll take a better look in the afternoon. My problem was in the conditional logic being used.


Thanks a lot Jamie.




Link to comment
Share on other sites

Just look at it in my laptop and works great, this definitely should do the trick.


Thanks again Jamie.



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