Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onResponderRelease not working on Android #11418

Closed
Piwaii opened this issue Dec 12, 2016 · 16 comments
Closed

onResponderRelease not working on Android #11418

Piwaii opened this issue Dec 12, 2016 · 16 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@Piwaii
Copy link
Contributor

Piwaii commented Dec 12, 2016

Description

onResponderRelease is not triggered in a ScrollView on Android, it works fine on IOS.

Reproduction

Just bind something on the 'onResponderRelease', it will work on IOS, not on Android
Exemple here : https://rnplay.org/apps/2rkKsA

Additional Information

  • Tested on React Native version: 0.39
  • Platform: ok on IOS, fails on Android
@Piwaii
Copy link
Contributor Author

Piwaii commented Dec 12, 2016

for information, this issue reopens this one : #8177

@shahen94
Copy link

#9447

@noobG
Copy link

noobG commented Dec 14, 2016

Same problem here. I'm getting the onResponderGrant event just fine, but the onResponderRelease doesn't fire (at least not consistently; if I do fast jittery movements the event sometimes fires).

To clarify:

<ScrollView 
	onMoveShouldSetResponder={() => true}
	onResponderGrant={() => console.log("Scrolling")}
	onResponderRelease={() => console.log("Done scrolling")}
	horizontal 
	showsHorizontalScrollIndicator={false}
	ref={(ref) => this.scrollView = ref}
>
   ...
</ScrollView>

RN version: 0.38.1

@philographer
Copy link
Contributor

  • 1 same here

@eggytronixx
Copy link

Has anyone found a work around yet?

@amitpdev
Copy link

amitpdev commented Apr 5, 2017

Should intercept the touch event before release can be intercepted.
Try this:

onStartShouldSetResponder={() => true}
onResponderRelease={() => this._onRowTap(prop)}

@zachrnolan
Copy link

zachrnolan commented Apr 21, 2017

+1 - on RN 0.43.3

@scotbond tried setting onStartShouldSetResponder, but didn't fix it.

@t-benze
Copy link

t-benze commented May 4, 2017

same +1. I ended up using the following to keep track

onScrollEndDrag={this.handleStartDragging}
onScrollBeginDrag={this.handleEndDragging}

@hramos hramos added the Icebox label Jul 20, 2017
@hramos
Copy link
Contributor

hramos commented Jul 20, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos closed this as completed Jul 20, 2017
@JaxGit
Copy link

JaxGit commented Oct 3, 2017

same with [email protected]
it seems that when swiping, onResponderGrant is fired, however onResponderMove and onResponderRelease could only be tracked within a tiny distance.
After swiping for a certain distance, onResponderMove loses tracking first, then onResponderRelease will never be fired when release.

@AugustoAleGon
Copy link

AugustoAleGon commented Nov 9, 2017

This is still not working! RN- 0.48

@jukben
Copy link

jukben commented Nov 28, 2017

Same issue 0.49.3 😢

I used onMomentumScrollEnd as hotfix.

@jayasme
Copy link

jayasme commented Jan 9, 2018

Still not fixed on 0.51.0
When you guys notice this issue?

@kkkelicheng
Copy link

I want to use this feature to solve the problem that mapView inside scrollview .
I use onResponderRelease well on iOS,
but on android , onResponderRelease sometimes not fire.
My RN version 0.44

@tsaohucn
Copy link

tsaohucn commented Mar 9, 2018

Me too even in last version 0.54

@kkkelicheng
Copy link

here is some code I used , may help someone whose MapView in Scrollview.
my page rootView is scrollview , I use custom view contain mapView. then I put custom view in scrollview.

// In custom view 

// add some touch event
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) {
            if(mySv != null){
                mySv.requestDisallowInterceptTouchEvent(false);
            }
        }
        if(ev.getAction() == MotionEvent.ACTION_DOWN){
            if(mySv != null){
                mySv.requestDisallowInterceptTouchEvent(true);
            }
        }
        return false;
    }

@Override
    public boolean onTouchEvent(MotionEvent event) {
        return true;
    }

// get ScrollView
    public ScrollView getParentView(ViewGroup view){
        ViewParent parent = view.getParent();
        if(parent == null){
            return null;
        }
        if(parent instanceof ScrollView){
            ScrollView sv = (ScrollView)parent;
            return sv;
        }
        else {
            if(parent instanceof ViewGroup){
                ViewGroup forceView = (ViewGroup)parent;
                return getParentView(forceView);
            }
            else {
                return null;
            }
        }
    }

//when init ,find out scrollview
 public CustomView(Context context) {
        // .........
        final CustomView thisView = this;
        this.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                Log.w("getViewTreeObserver","layout donw");
                thisView.getViewTreeObserver()
                        .removeOnGlobalLayoutListener(this);
                ScrollView sv = thisView.getParentView(thisView);
                if(sv != null){
                    thisView.mySv = sv;
                }
            }
        });

    }

then In ReactNative , You need not handle touch event to block scollView scoll, otherwise It may cause error.

<ScrollView>
    <View style={styles.mapContainer}>
                            <MapView
                                style={styles.mapStyle}
                                ref={this.mapRef}
                            />
      </View>
</ScrollView>

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests