This repository has been archived by the owner on Nov 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: consider both velocity and position while calculating index (#802)
Motivation Previously evaluating next index was based only on position OR velocity. It wasn't considering BOTH of them which appears to natural behavior. I believe that the expected scenario is that we can calculate is component left without snapping will rather stop decaying on the current or next/previous page. I figured out (calculation attached) that final position (actually delta of current and final extrapolated) is ~ to v^2 and knowing that I implemented a more physical-based model for evaluating next index. Changes I changed the implementation of calculating the next index. Also, I had to drop swipeVelocityThreshold and swipeDistanceThreshold and then I replaced it with swipeVelocityImpact. I think it's a good time for this move bc it's not very breaking and this version is not yet by default in react-navigation. swipeVelocityImpact is a factor in delta pos = a * v^2
- Loading branch information
Showing
4 changed files
with
41 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters