Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolate snapping/resticting with the endOnly option when inertia isn't triggered #69

Merged
merged 7 commits into from
Sep 4, 2014

Conversation

taye
Copy link
Owner

@taye taye commented Aug 31, 2014

If inertia is enabled on an Interactable, snap/restrict has the endOnly set to true and snap/restict occurs when the pointer is release without triggering inertia, then the event coordinates will be animated from the release location to the snapped/restricted location.

interact('*')
  .inertia()
  .snap({mode: ..., endOnly: true})
  .restrict({drag: {...}, endOnly: true});

The duration of the animation can be set with

interact('*').inertia({
  smoothEndDuration: 300 //  the duration in ms
})

Closes #48

@taye
Copy link
Owner Author

taye commented Aug 31, 2014

@jordandh I've implemented this a little differently to how I imagined before. Rather than having a smoothEnd option in snap and restrict, it just happens automatically if inertia is enabled and snap or restrict endOnly is true.

If you have time to test it I'd greatly appreciate it!

@jordandh
Copy link

jordandh commented Sep 1, 2014

@taye I will take a look at this this week. Hopefully tomorrow or Wednesday.

@jordandh
Copy link

jordandh commented Sep 3, 2014

@taye I tried out the snap-restrict-smooth-end branch and it works well for the most part. I was even able to remove my draginertiastart handler code because your changes do the job for it.

The only problem I noticed happens when you begin a drag during another drag's inertia phase. The interactable snaps to the incorrect coordinates. This may be due to the way I use the snap functionality. First I set the snap on the interactable like so:

.snap({
  mode: 'anchor',
  endOnly: true
})

And in my dragstart handler I set the anchorPoints as described here #32 (comment)

I'll post again if I obtain more information.

@taye
Copy link
Owner Author

taye commented Sep 3, 2014

I think that the fix for the inertia zeroResumeDelta issue is ready now and that should fix the problem you described above. I'll start merging things and hoping that they aren't too broken :).

@taye taye merged commit b3a5b55 into master Sep 4, 2014
@taye taye deleted the snap-restrict-smooth-end branch September 8, 2014 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Animate Snapping and Restricting when there is no Inertia
2 participants