From 6a16bec882cba809bdf9027367b76f6543b6617d Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Sun, 1 Jul 2018 16:30:40 -0700 Subject: [PATCH] RN: Fix Drawing Rect for ReactScrollView Summary: Fixes `ReactScrollView` so that it respects the drawing rect (i.e. the bounding box of the element). In JavaScript, this is the backing view for `ScrollView` (vertical) on Android. Reviewed By: fadinghorse Differential Revision: D8710256 fbshipit-source-id: f3bd96e39b8569cfcb21e486944b70fdb57c12b6 --- .../src/main/java/com/facebook/react/uimanager/ViewProps.java | 1 + .../java/com/facebook/react/views/scroll/ReactScrollView.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java index 29ed6e96c..0a353a6b0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java @@ -102,6 +102,7 @@ public class ViewProps { public static final String OVERFLOW = "overflow"; public static final String HIDDEN = "hidden"; + public static final String SCROLL = "scroll"; public static final String VISIBLE = "visible"; public static final String ALLOW_FONT_SCALING = "allowFontScaling"; diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java index acf3458ef..57b401cd6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java @@ -47,6 +47,7 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou private final OnScrollDispatchHelper mOnScrollDispatchHelper = new OnScrollDispatchHelper(); private final @Nullable OverScroller mScroller; private final VelocityHelper mVelocityHelper = new VelocityHelper(); + private final Rect mRect = new Rect(); // for reuse to avoid allocation private @Nullable Rect mClippingRect; private boolean mDoneFlinging; @@ -351,6 +352,8 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou mEndBackground.draw(canvas); } } + getDrawingRect(mRect); + canvas.clipRect(mRect); super.draw(canvas); }