You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 27, 2022. It is now read-only.
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
Copy file name to clipboardExpand all lines: README.md
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -287,13 +287,9 @@ String indicating whether the keyboard gets dismissed in response to a drag gest
287
287
288
288
Boolean indicating whether to enable swipe gestures. Swipe gestures are enabled by default. Passing `false` will disable swipe gestures, but the user can still switch tabs by pressing the tab bar.
289
289
290
-
##### `swipeDistanceThreshold`
290
+
##### `swipeVelocityImpact`
291
291
292
-
Minimum swipe distance which triggers a tab switch. By default, this is automatically determined based on the screen width.
293
-
294
-
##### `swipeVelocityThreshold`
295
-
296
-
Minimum swipe velocity which triggers a tab switch. Defaults to `1200`.
292
+
Determines how relevant is a velocity while calculating next position while swiping. Defaults to `0.01`.
0 commit comments