|
1 | 1 | package com.rnds;
|
2 | 2 |
|
| 3 | +import android.util.Log; |
3 | 4 | import android.animation.ObjectAnimator;
|
4 | 5 | import android.content.Context;
|
5 | 6 | import android.graphics.Matrix;
|
@@ -31,6 +32,8 @@ public class DirectedScrollView extends ReactViewGroup {
|
31 | 32 | private float minimumZoomScale = 1.0f;
|
32 | 33 | private float maximumZoomScale = 1.0f;
|
33 | 34 | private boolean bounces = true;
|
| 35 | + private boolean verticalBounceEnabled = true; |
| 36 | + private boolean horizontalBounceEnabled = true; |
34 | 37 | private boolean alwaysBounceVertical = false;
|
35 | 38 | private boolean alwaysBounceHorizontal = false;
|
36 | 39 | private boolean bouncesZoom = true;
|
@@ -214,7 +217,7 @@ private void onActionMove(MotionEvent motionEvent) {
|
214 | 217 | scrollY = startScrollY + deltaY;
|
215 | 218 |
|
216 | 219 | if (bounces) {
|
217 |
| - clampAndTranslateChildren(false, getMaxScrollY() <= 0 && !alwaysBounceVertical, getMaxScrollX() <= 0 && !alwaysBounceHorizontal); |
| 220 | + clampAndTranslateChildren(false, !verticalBounceEnabled || (getMaxScrollY() <= 0 && !alwaysBounceVertical), !horizontalBounceEnabled || (getMaxScrollX() <= 0 && !alwaysBounceHorizontal)); |
218 | 221 | } else {
|
219 | 222 | clampAndTranslateChildren(false);
|
220 | 223 | }
|
@@ -433,6 +436,14 @@ public void setBouncesZoom(final boolean bouncesZoom) {
|
433 | 436 | this.bouncesZoom = bouncesZoom;
|
434 | 437 | }
|
435 | 438 |
|
| 439 | + public void setVerticalBounceEnabled(final boolean verticalBounceEnabled) { |
| 440 | + this.verticalBounceEnabled = verticalBounceEnabled; |
| 441 | + } |
| 442 | + |
| 443 | + public void setHorizontalBounceEnabled(final boolean horizontalBounceEnabled) { |
| 444 | + this.horizontalBounceEnabled = horizontalBounceEnabled; |
| 445 | + } |
| 446 | + |
436 | 447 | public void setAlwaysBounceHorizontal(final boolean alwaysBounceHorizontal) {
|
437 | 448 | this.alwaysBounceHorizontal = alwaysBounceHorizontal;
|
438 | 449 | }
|
|
0 commit comments