|
40 | 40 | import com.facebook.react.modules.i18nmanager.I18nUtil;
|
41 | 41 | import com.facebook.react.uimanager.FabricViewStateManager;
|
42 | 42 | import com.facebook.react.uimanager.MeasureSpecAssertions;
|
| 43 | +import com.facebook.react.uimanager.PointerEvents; |
43 | 44 | import com.facebook.react.uimanager.ReactClippingViewGroup;
|
44 | 45 | import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
|
45 | 46 | import com.facebook.react.uimanager.ReactOverflowViewWithInset;
|
@@ -105,6 +106,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
|
105 | 106 | private final FabricViewStateManager mFabricViewStateManager = new FabricViewStateManager();
|
106 | 107 | private final ReactScrollViewScrollState mReactScrollViewScrollState;
|
107 | 108 | private final ValueAnimator DEFAULT_FLING_ANIMATOR = ObjectAnimator.ofInt(this, "scrollX", 0, 0);
|
| 109 | + private PointerEvents mPointerEvents = PointerEvents.AUTO; |
108 | 110 |
|
109 | 111 | private final Rect mTempRect = new Rect();
|
110 | 112 |
|
@@ -452,6 +454,11 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
|
452 | 454 | return false;
|
453 | 455 | }
|
454 | 456 |
|
| 457 | + // We intercept the touch event if the children are not supposed to receive it. |
| 458 | + if (!PointerEvents.canChildrenBeTouchTarget(mPointerEvents)) { |
| 459 | + return true; |
| 460 | + } |
| 461 | + |
455 | 462 | try {
|
456 | 463 | if (super.onInterceptTouchEvent(ev)) {
|
457 | 464 | NativeGestureUtil.notifyNativeGestureStarted(this, ev);
|
@@ -519,6 +526,11 @@ public boolean onTouchEvent(MotionEvent ev) {
|
519 | 526 | return false;
|
520 | 527 | }
|
521 | 528 |
|
| 529 | + // We do not accept the touch event if this view is not supposed to receive it. |
| 530 | + if (!PointerEvents.canBeTouchTarget(mPointerEvents)) { |
| 531 | + return false; |
| 532 | + } |
| 533 | + |
522 | 534 | mVelocityHelper.calculateVelocity(ev);
|
523 | 535 | int action = ev.getAction() & MotionEvent.ACTION_MASK;
|
524 | 536 | if (action == MotionEvent.ACTION_UP && mDragging) {
|
@@ -1253,4 +1265,12 @@ public int getFlingExtrapolatedDistance(int velocityX) {
|
1253 | 1265 | this, velocityX, 0, Math.max(0, computeHorizontalScrollRange() - getWidth()), 0)
|
1254 | 1266 | .x;
|
1255 | 1267 | }
|
| 1268 | + |
| 1269 | + public void setPointerEvents(PointerEvents pointerEvents) { |
| 1270 | + mPointerEvents = pointerEvents; |
| 1271 | + } |
| 1272 | + |
| 1273 | + public PointerEvents getPointerEvents() { |
| 1274 | + return mPointerEvents; |
| 1275 | + } |
1256 | 1276 | }
|
0 commit comments