|
18 | 18 | import com.facebook.react.views.view.ReactViewGroup; |
19 | 19 |
|
20 | 20 | public class SpringScrollView extends ReactViewGroup implements View.OnLayoutChangeListener, SpringAnimatorListener { |
21 | | - private float refreshHeaderHeight, loadingFooterHeight; |
| 21 | + private float refreshHeaderHeight, loadingFooterHeight, decelerationRate; |
22 | 22 | private boolean momentumScrolling, bounces, scrollEnabled, dragging, inverted, |
23 | | - directionalLockEnabled, pagingEnabled, shouldVerticalRebound; |
| 23 | + directionalLockEnabled, pagingEnabled; |
24 | 24 | private VelocityTracker tracker; |
25 | 25 | private SpringAnimator verticalAnimation, horizontalAnimation; |
26 | 26 | private String refreshStatus, loadingStatus, draggingDirection; |
@@ -258,12 +258,12 @@ private void onUp(MotionEvent evt) { |
258 | 258 | sendEvent("onCustomMomentumScrollBegin", null); |
259 | 259 | } |
260 | 260 | float maxY = contentSize.height + contentInsets.bottom - size.height; |
261 | | - verticalAnimation.startInner(contentOffset.y, -vy, pagingEnabled ? 0.99f : 0.997f, |
| 261 | + verticalAnimation.startInner(contentOffset.y, -vy, pagingEnabled ? 0.99f : decelerationRate, |
262 | 262 | -contentInsets.top, maxY, pagingEnabled, getPageHeight()); |
263 | 263 |
|
264 | 264 | if (contentSize.width <= size.width) return; |
265 | 265 | float maxX = contentSize.width - size.width + contentInsets.right; |
266 | | - horizontalAnimation.startInner(contentOffset.x, -vx, pagingEnabled ? 0.99f : 0.997f, |
| 266 | + horizontalAnimation.startInner(contentOffset.x, -vx, pagingEnabled ? 0.99f : decelerationRate, |
267 | 267 | -contentInsets.left, maxX, pagingEnabled, getPageWidth()); |
268 | 268 | } |
269 | 269 |
|
@@ -455,6 +455,10 @@ public void scrollTo(float x, float y, boolean animated) { |
455 | 455 | } |
456 | 456 | } |
457 | 457 |
|
| 458 | + public void setDecelerationRate(float rate){ |
| 459 | + decelerationRate = rate; |
| 460 | + } |
| 461 | + |
458 | 462 | public void setBounces(boolean bounces) { |
459 | 463 | this.bounces = bounces; |
460 | 464 | } |
|
0 commit comments