Skip to content

iOS height calculation is wrong? #389

Open
@cristianoccazinsp

Description

@cristianoccazinsp

Can you guys review this? https://github.com/APSL/react-native-keyboard-aware-scroll-view/blob/master/lib/KeyboardAwareHOC.js#L391

First, you are using a default extra height of 75 (probably to account for some height of an input). This is already a bit odd.

However, on the above code you are using the input's bottom location to decide if the screen should scroll or not. This seems fine, but you are also adding the extra height (which is also fine). What is wrong, however, is that you are not using the input's bottom location to actually scroll. You should be also adding the input height to the extra height calculation at the scroll code here (https://github.com/APSL/react-native-keyboard-aware-scroll-view/blob/master/lib/KeyboardAwareHOC.js#L463). If you did this, you wouldn't need a 75 default for extra height and a 0 would scroll just fine to the bottom of the element.

With the above, the final result is that you are adding some extra height to correctly scroll to the bottom of the input, but this also causes the checks to fire earlier (because you are using the bottom of the input + extra height to decide if scrolling or not). So you are basically checking to scroll for 1 value (input bottom + extra height), but only scrolling to input top + extra height. This makes scrolling very odd.

I can't tell if this is an issue also for Android since I'm not using it in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions