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

[Android] [Lists] Workaround a wrong fling direction for inverted ScrollViews on Android P #21117

Closed
wants to merge 1 commit into
base: master
from

Conversation

@mandrigin
Copy link
Contributor

mandrigin commented Sep 14, 2018

This is a safe workaround to an issue in Android P: https://issuetracker.google.com/issues/112385925

It is based on a fact that even though fling receive a wrong sign in velocityY, mOnScrollDispatchHelper.getYFlingVelocity() still returns a fling direction.

Fixes #19434

Test Plan:

  1. Create a test application with a FlatList with inverted={true}.
  2. Fill it with data
  3. Scroll and release your finger

Expected:
On Android 8 and 9 the behaviour is the same.

Release Notes:

[ANDROID] [BUGFIX] [ScrollView] - Workaround a wrong fling direction for inverted ScrollViews on Android P

@mandrigin mandrigin force-pushed the mandrigin:workaround/fling-on-android-P branch 2 times, most recently from 59cf86c to 107a9ec Sep 14, 2018

@mandrigin mandrigin changed the title [Android] [ScrollView] Workaround a wrong fling direction for inverted ScrollViews on Android P [Android] [Lists] Workaround a wrong fling direction for inverted ScrollViews on Android P Sep 14, 2018

danalloway added a commit to diehappy/react-native that referenced this pull request Sep 14, 2018

chrisnojima added a commit to keybase/react-native that referenced this pull request Sep 17, 2018

danalloway added a commit to diehappy/react-native that referenced this pull request Sep 17, 2018

chrisnojima added a commit to keybase/react-native that referenced this pull request Oct 15, 2018

//
// Hence, we can use the absolute value from whatever the OS gives
// us and use the sign of what mOnScrollDispatchHelper has tracked.
velocityY = (int)(Math.abs(velocityY) * Math.signum(mOnScrollDispatchHelper.getYFlingVelocity()));

This comment has been minimized.

@listicos

listicos Nov 7, 2018

I tested this and is working, what is not so good practice in general is changing the argument value, instead create a new var. Thank you for this!

This comment has been minimized.

@mandrigin

mandrigin Nov 7, 2018

Author Contributor

Thanks for reviewing!
I’m away from my laptop this week, will address you comment on Monday.

This comment has been minimized.

@kelset

kelset Nov 12, 2018

Collaborator

I agree with Ruben's feedback, once the PR is updated I'll try to import it :) Thanks for doing this btw 👏

This comment has been minimized.

@mandrigin

mandrigin Nov 13, 2018

Author Contributor

Thanks a lot!
Yeah, I agree about a variable, just wanted to make a smallest possible diff.
I fixed it and rebased to the latest master.

@watadarkstar

This comment has been minimized.

Copy link

watadarkstar commented Nov 8, 2018

We will be using this in production until it gets merged! 👍 CC: @listicos who reviewed this for us on our team!

@mandrigin mandrigin force-pushed the mandrigin:workaround/fling-on-android-P branch from 107a9ec to f9ed777 Nov 13, 2018

@mandrigin mandrigin force-pushed the mandrigin:workaround/fling-on-android-P branch from f9ed777 to 1ae9b9a Nov 13, 2018

@pull-bot

This comment has been minimized.

Copy link

pull-bot commented Nov 13, 2018

Warnings
⚠️

📋 Release Notes - This PR may have incorrectly formatted Release Notes.

Generated by 🚫 dangerJS

chrisnojima added a commit to keybase/react-native that referenced this pull request Nov 14, 2018

@mandrigin

This comment has been minimized.

Copy link
Contributor Author

mandrigin commented Nov 15, 2018

@listicos @kelset please ping me if anything else needs to be done in this PR 🙂
I assume the feedback is addressed and it is rebased. I don't know why analyze fails, it doesn't seem to be related to my changes.

@kelset

This comment has been minimized.

Copy link
Collaborator

kelset commented Nov 15, 2018

Hey Igor, thanks!

I'll try to trigger the import, but can't assure when it will land because this past week the FB team seemed super busy 🤷‍♂️

@facebook-github-bot shipit

@facebook-github-bot
Copy link

facebook-github-bot left a comment

@kelset is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot

This comment has been minimized.

Copy link
Collaborator

react-native-bot commented Nov 15, 2018

@mandrigin merged commit b971c5b into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Nov 15, 2018

kelset added a commit that referenced this pull request Nov 26, 2018

Workaround a wrong fling direction for inverted ScrollViews on Androi…
…d P (#21117)

Summary:
This is a safe workaround to an issue in Android P: https://issuetracker.google.com/issues/112385925

It is based on a fact that even though `fling` receive a wrong sign in `velocityY`, `mOnScrollDispatchHelper.getYFlingVelocity()` still returns a fling direction.

Fixes #19434
Pull Request resolved: #21117

Differential Revision: D13082740

Pulled By: hramos

fbshipit-source-id: 1b28586d2c7bdcae4a111d3cead4a0455cebb99a

sjchmiela added a commit to expo/react-native that referenced this pull request Dec 15, 2018

Workaround a wrong fling direction for inverted ScrollViews on Androi…
…d P (facebook#21117)

Summary:
This is a safe workaround to an issue in Android P: https://issuetracker.google.com/issues/112385925

It is based on a fact that even though `fling` receive a wrong sign in `velocityY`, `mOnScrollDispatchHelper.getYFlingVelocity()` still returns a fling direction.

Fixes facebook#19434
Pull Request resolved: facebook#21117

Differential Revision: D13082740

Pulled By: hramos

fbshipit-source-id: 1b28586d2c7bdcae4a111d3cead4a0455cebb99a

sjchmiela added a commit to expo/react-native that referenced this pull request Dec 15, 2018

Workaround a wrong fling direction for inverted ScrollViews on Androi…
…d P (facebook#21117)

Summary:
This is a safe workaround to an issue in Android P: https://issuetracker.google.com/issues/112385925

It is based on a fact that even though `fling` receive a wrong sign in `velocityY`, `mOnScrollDispatchHelper.getYFlingVelocity()` still returns a fling direction.

Fixes facebook#19434
Pull Request resolved: facebook#21117

Differential Revision: D13082740

Pulled By: hramos

fbshipit-source-id: 1b28586d2c7bdcae4a111d3cead4a0455cebb99a

JunielKatarn added a commit to JunielKatarn/react-native that referenced this pull request Feb 11, 2019

Workaround a wrong fling direction for inverted ScrollViews on Androi…
…d P (facebook#21117)

Summary:
This is a safe workaround to an issue in Android P: https://issuetracker.google.com/issues/112385925

It is based on a fact that even though `fling` receive a wrong sign in `velocityY`, `mOnScrollDispatchHelper.getYFlingVelocity()` still returns a fling direction.

Fixes facebook#19434
Pull Request resolved: facebook#21117

Differential Revision: D13082740

Pulled By: hramos

fbshipit-source-id: 1b28586d2c7bdcae4a111d3cead4a0455cebb99a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.