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

Only scroll to view when view is hidden under keyboard #9

Open
Andreyco opened this issue Jun 25, 2016 · 5 comments
Open

Only scroll to view when view is hidden under keyboard #9

Andreyco opened this issue Jun 25, 2016 · 5 comments

Comments

@Andreyco
Copy link

See the attachment. Such handling looks messy and should not happen.

unnecessary-scroll

@kaplanitay
Copy link

Having the same issue.
Is there a fix?

@Andreyco
Copy link
Author

Andreyco commented Feb 8, 2017

I haven't worked on PR, or anything else... The solution is to determine focused element/input coordinates and compare those to keyboard's coordinates. If keyboard does not cover focused element/input, prevent scrolling.

Some time ago I posted this issue on RN's issues.

Take a look at scrollscrollResponderInputMeasureAndScrollToKeyboardIfCovered, it might help.

shakyShane added a commit to shakyShane/react-native-keyboard-aware-scrollview that referenced this issue May 4, 2017
@shakyShane
Copy link

shakyShane commented May 4, 2017

@artald I didn't send a PR since I was unsure if you either would accept this feature, or would want to implement in another way.

But, for others out there you can see how I made this work in the following commit shakyShane@873cca3

the usage would be

<KeyboardAwareScrollView
    getTextInputRefs={() => [this._ref1, this._ref2]}
    scrollToInputIfNotHidden={false}
>
   ... 
</KeyboardAwareScrollView>

excuse the clunky naming - I wanted to keep the default set to true for back compat

@artald
Copy link
Collaborator

artald commented May 4, 2017

@shakyShane that's great, thanks!

The naming indeed seems a bit confusing, but I understand regarding the backwards compatibility reasons. I would also perform a small refactor - not measure the height anyway if it's the default prop, maybe extract the actual scrolling to input to another method.

You can totally go ahead and make this PR, maybe we can change some small stuff. If you prefer I can just take your commit and do it myself sometime soon. It's up to you 😀.
Thanks.

@shakyShane
Copy link

Thanks for the reply.

Yep I'll send a PR with your suggestions.

Naming that prop though.... :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants