Skip to content

Commit 0deb956

Browse files
committed
fixed the bug: nested scrollView cannot scroll correctly
1 parent 02befe1 commit 0deb956

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

android/src/main/java/com/reactnativecomponent/swiperefreshlayout/RCTSwipeRefreshLayout.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.support.v4.view.NestedScrollingParent;
99
import android.support.v4.view.NestedScrollingParentHelper;
1010
import android.support.v4.view.ViewCompat;
11+
import android.support.v4.widget.SwipeRefreshLayout;
1112
import android.util.AttributeSet;
1213
import android.util.DisplayMetrics;
1314
import android.util.Log;
@@ -239,10 +240,6 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
239240
// mInitialMotionY = mInitialDownY + mTouchSlop;
240241
mIsBeingDragged = !canChildScrollUp(yDiff);
241242

242-
if (shouldInterceptTouchEvent(ev)) {
243-
NativeGestureUtil.notifyNativeGestureStarted(this, ev);
244-
}
245-
246243
return mIsBeingDragged;
247244
}
248245
break;
@@ -295,16 +292,16 @@ private float getMotionEventY(MotionEvent ev, int activePointerId) {
295292
return MotionEventCompat.getY(ev, index);
296293
}
297294

295+
/**
296+
* {@link SwipeRefreshLayout} overrides {@link ViewGroup#requestDisallowInterceptTouchEvent} and
297+
* swallows it. This means that any component underneath SwipeRefreshLayout will now interact
298+
* incorrectly with Views that are above SwipeRefreshLayout. We fix that by transmitting the call
299+
* to this View's parents.
300+
*/
298301
@Override
299-
public void requestDisallowInterceptTouchEvent(boolean b) {
300-
// if this is a List < L or another view that doesn't support nested
301-
// scrolling, ignore this request so that the vertical scroll event
302-
// isn't stolen
303-
if ((android.os.Build.VERSION.SDK_INT < 21 && mTarget instanceof AbsListView)
304-
|| (mTarget != null && !ViewCompat.isNestedScrollingEnabled(mTarget))) {
305-
// Nope.
306-
} else {
307-
super.requestDisallowInterceptTouchEvent(b);
302+
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
303+
if (getParent() != null) {
304+
getParent().requestDisallowInterceptTouchEvent(disallowIntercept);
308305
}
309306
}
310307

0 commit comments

Comments
 (0)