Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

iOS scroll issue #43

Closed
wamphlett opened this issue Nov 12, 2018 · 5 comments
Closed

iOS scroll issue #43

wamphlett opened this issue Nov 12, 2018 · 5 comments

Comments

@wamphlett
Copy link

I am experiencing a strange scroll is on iOS. When focusing an input or the content size changes, the screen scrolls up out of view.

I've debugged this somewhat and I can see the issue is coming from the _onRef function. Specifically, y in measureInWindow returns about 700 meaning that the scroll calculation is always out. If I add a delay to the setTimeout, e.g.

setTimeout(() => {
            this._root._innerViewRef &&
            this._root._innerViewRef.measureInWindow((x, y) => {
                this._topOffset = y;
            });
        }, 1000);

then y becomes 25 and the scrolling works exactly as expected. Im not sure what the purpose of this _onRef function is and Im not confident that my solution is the best - feels hacky without knowing what this function is supposed to be doing.

Perhaps I am doing something wrong somewhere else but I feel like I have exhausted all attempts to resolve this now. Are you able to help?

@baijunjie
Copy link
Owner

Very strange.

Sometimes ScrollView is not at the top of the page, it may be below topBar, so get this offset when you initialize.

The question is, why do you get 700 when initialize? It's either a react-native bug or you change its position after initialization.

Can you reproduce this problem in __test__?

@robertobrogi
Copy link

Hi, i have the same issue :(
in Ios i have the very height scroll!

@baijunjie
Copy link
Owner

@robertobrogi Hi, I can't reproduce this problem. Can you provide a simple demo to reproduce this problem?

@baijunjie
Copy link
Owner

If there is any new feedback, please open it again

@baijunjie
Copy link
Owner

Thank you for your help.
I found the problem. The problem is that the screen enters the screen dynamically, and the automatic topOffset is wrong in the initial stage. Now try v1.9.0 and set the topOffset props manually.

Suppose TopBar.height=60

<InputScrollView topOffset={TopBar.height}>
         ...
</InputScrollView>

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

No branches or pull requests

3 participants