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

fix #10747 (ScrollView rendered incorrectly with RefreshControl) #15033

Closed
wants to merge 1 commit into from

Conversation

vonovak
Copy link
Contributor

@vonovak vonovak commented Jul 16, 2017

set the y offset to 0, since 0 offset is where we want to be after we hide the refreshControl.

Tested in emulator with ios 8, 9, 10 and also with section headers.

set the y offset to 0, since 0 offset is where we want to be after we hide the refreshControl
@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Jul 16, 2017
@vonovak vonovak changed the title fix #10747 fix #10747 (ScrollView rendered incorrectly with RefreshControl) Jul 16, 2017
@shergin
Copy link
Contributor

shergin commented Jul 17, 2017

Why does it work?

@vonovak
Copy link
Contributor Author

vonovak commented Jul 22, 2017

@shergin I'll try to explain with a couple of screenshots:

lightblue is refreshControl, green is listView

1 . note I hardcoded the -120 points offset and commented out the [super endRefreshing]. This screenshot is stopped at a breakpoint.

screen shot 2017-07-22 at 13 41 31

2 . The same code after the method finishes. One can see the 60 points of RefreshControl (lightblue), and the next 60 points of ListView (green) from the 120 points of offset

screen shot 2017-07-22 at 13 41 43

3 . This is how the current master behaves when the [super endRefreshing] is commented out.

screen shot 2017-07-22 at 13 45 26

4 . this is the current behavior of master, the call to [super endRefreshing] does two things (compare with the previous screenshot):

contentOffset:
The point at which the origin of the content view is offset from the origin of the scroll view.

screen shot 2017-07-22 at 13 46 01

5 . when 0 is used for the y offset and [super endRefreshing] is commented out, the scrollView correctly goes all the way up. This is essentially the fix, but of course the [super endRefreshing] should still be called.

screen shot 2017-07-22 at 13 49 28

@vonovak
Copy link
Contributor Author

vonovak commented Aug 16, 2017

ping @shergin does this look good enough?

@vonovak
Copy link
Contributor Author

vonovak commented Sep 5, 2017

Ping @shergin @janicduplessis does this look good?

@shergin
Copy link
Contributor

shergin commented Sep 5, 2017

I am sorry, I have not chance to look at this yet. 😞
@janicduplessis Does it look good for you?

@janicduplessis
Copy link
Contributor

I think this is fine, makes sense that we should set y content offset to 0.

@shergin
Copy link
Contributor

shergin commented Sep 7, 2017

Wait a second, we just found in another diff that initial contentOffset can be negative and actually directly related to contentInsets!
Right? So, why should we scroll to 0?

@shergin
Copy link
Contributor

shergin commented Sep 7, 2017

@vonovak I am really sorry, but I cannot accept your explanation. 😢

@vonovak
Copy link
Contributor Author

vonovak commented Sep 7, 2017

@shergin can you point me to such diff?

@shergin
Copy link
Contributor

shergin commented Sep 9, 2017

See discussion here:
https://github.com/facebook/react-native/pull/15395/files/44a5ec87d1c06f4fb52bb5602f62b9015f76a786#diff-973dcd0e3fbfcc5e35485bb6404a2fd2

And follow up diff:
950c2b2

And great article about ScrollView: https://www.objc.io/issues/3-views/scroll-view/

I am not sure, honestly. May be I am wrong here.
¯\_(ツ)_/¯

@facebook-github-bot
Copy link
Contributor

@vonovak I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@ngandhy
Copy link
Contributor

ngandhy commented Oct 18, 2017

@shergin / @janicduplessis - Why would it not "end refreshing" on 0? The if statement above the change and comment above that both imply that at the end of refreshing it should no longer be negative. What other valid values are allowed and if so should they just be temporarily stored in beginRefreshing and replaced in endRefreshing?

"-scrollView.contentInset.top" doesn't seem to make sense for end offset value... as shown by the bugs it's creating.

@vonovak - thanks for repeatedly trying to fix this issue. It's appreciated

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Nov 7, 2017
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

cdlewis pushed a commit to cdlewis/react-native that referenced this pull request Nov 19, 2017
Summary:
set the y offset to 0, since 0 offset is where we want to be after we hide the refreshControl.

Tested in emulator with ios 8, 9, 10 and also with section headers.
Closes facebook#15033

Differential Revision: D6265930

Pulled By: shergin

fbshipit-source-id: b249c4713de68fc6b3a32cee7f995dc352315970
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants