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

Support inverted ScrollView on macOS #1264

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

christophpurrer
Copy link

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

Allow to render a scrollView's content in inverted order which is especially helpful in messaging applications.

Co-authored-by: Scott Kyle [email protected]

Changelog

[macOS] [Added] - Support inverted ScrollView on macOS

Test Plan

Added RNTester example

Screen.Recording.2022-07-20.at.4.30.22.PM.mov

Default, non-inverted example

Screen.Recording.2022-07-20.at.4.39.55.PM.mov

@christophpurrer christophpurrer requested a review from a team as a code owner July 20, 2022 23:41
@Saadnajmi
Copy link
Collaborator

The goal of this PR is that instead of doing a scale transformation on the scrollview contents like Flatlist on iOS does, we're instead taking advantage of macOS's flipped coordinate space?

@christophpurrer
Copy link
Author

@Saadnajmi > This is an internal change we have used at Meta because

We can't rely on -1 scale hacks on macOS because of inverse issues with trackpad/scrollwheel, dragging scrollbars, tracking hovers, etc.

Hence we added 'native' support for inverted views

@Saadnajmi Saadnajmi self-assigned this Jul 22, 2022
Copy link
Collaborator

@Saadnajmi Saadnajmi left a comment

Choose a reason for hiding this comment

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

When I test the Flatlist example page (packages/rn-tester/js/examples/FlatList/FlatList-basic.js) with this change, all the elements seem inverted?

Interestingly enough, if I make an edit in a file (causing fast refresh), it fixes itself.

Screen.Recording.2022-07-22.at.11.20.46.AM.mov

@christophpurrer
Copy link
Author

Good catch! And easy to repro.

It fixes 'itself' when you edit FlatList-basic.js because fast refresh will reset the 'inverted' flag.

I'll look for a proper fix!

@christophpurrer
Copy link
Author

That latest version should both work with ScrollView and FlatList.
Demo:
https://www.youtube.com/shorts/TtXp9Laf9kQ

Would be great to get some additional verification as well

@Saadnajmi
Copy link
Collaborator

The latest iteration does indeed pass the "Basic" Flatlist test page, but seems to have no effect on both the Flatlist and SectionList "Inverted" test pages :/

Screen.Recording.2022-07-25.at.4.26.48.PM.mov

@christophpurrer christophpurrer changed the title Support inverted ScrollView on macOS Support inverted ScrollView on macOS [WIP] Aug 2, 2022
@Saadnajmi
Copy link
Collaborator

This PR looks like one we'd like to merge, but needs a bit more love for all of the test pages / use cases of Flatlist. Thanks for this fix!

@christophpurrer christophpurrer changed the title Support inverted ScrollView on macOS [WIP] [WIP] Support inverted ScrollView on macOS Aug 10, 2022
@ghost ghost removed the Needs: Author Feedback label Aug 10, 2022
@ghost ghost added the no-recent-activity label Aug 18, 2022
@ghost
Copy link

ghost commented Aug 18, 2022

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@Saadnajmi
Copy link
Collaborator

don't close, bot?

@ghost ghost removed the no-recent-activity label Aug 18, 2022
@ghost ghost added the no-recent-activity label Aug 25, 2022
@ghost
Copy link

ghost commented Aug 25, 2022

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@Saadnajmi
Copy link
Collaborator

Don't close?

@ghost ghost removed the no-recent-activity label Aug 25, 2022
@ghost ghost removed the Needs: Author Feedback label Aug 30, 2022
@christophpurrer christophpurrer changed the title [WIP] Support inverted ScrollView on macOS Support inverted ScrollView on macOS Aug 30, 2022
@christophpurrer
Copy link
Author

christophpurrer commented Aug 30, 2022

So it seems this always worked after all, however initially it never supported to change the inverted property on the fly / at runtime?
Is this actually a real usage scenario?

Anyway, supporting that behavior solves the issue in rn-tester as the previous manual resolution

Interestingly enough, if I make an edit in a file (causing fast refresh), it fixes itself.

To make it work I had to piggy-bag on a previous work-around > https://l.workplace.com/l.php?u=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Freact-native-macos%2Fblame%2Fmain%2FLibraries%2FComponents%2FScrollView%2FScrollView.js%23L1191&h=AT3fib22xIV2fmZMhNOJG8QMW7Wyff9Mb7mUrteHJQ1tgW6ZAyCefrhhTUDGNA9TPxzc7B9a7ciemm-px_U13LznEMFnxwbRmLX7ohWZALyeB60HNQDmqLDueA08-dbWqU6_w-w7BPPMb9uKazppMrxFRHfkJno8eM2QpQ

ScrollView sample added

ScrollView.mov

Flatlist inverted

FlatListInverted.mov

Flatlist basic

FlatList basic has a terrible performance so I restricted the max list size to 50 (from 1000)
https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/js/examples/FlatList/FlatList-basic.js#L269

And the incremental list expansion to 10 (from 100)
https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/js/examples/FlatList/FlatList-basic.js#L71
https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/js/examples/FlatList/FlatList-basic.js#L273

FlatListBasic480.mov

@christophpurrer christophpurrer force-pushed the scrollViewInverted branch 2 times, most recently from cc8087c to ea07b6f Compare August 30, 2022 06:16
@christophpurrer christophpurrer force-pushed the scrollViewInverted branch 2 times, most recently from 270ba00 to 8a052a5 Compare September 7, 2022 03:47
Copy link
Collaborator

@Saadnajmi Saadnajmi left a comment

Choose a reason for hiding this comment

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

Switched back to request changes for last comment, it would be bad to break iOS 😅

Allow to render a scrollView's content in inverted order which is especially helpful in messaging applications.

We can't rely on -1 scale hacks on macOS because of inverse issues with trackpad/scrollwheel, dragging scrollbars, tracking hovers, etc.

Hence we added 'native' support for inverted views
@christophpurrer
Copy link
Author

I have remove those changes

Copy link
Collaborator

@Saadnajmi Saadnajmi left a comment

Choose a reason for hiding this comment

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

Latest version lost my Flatlist keyboard nav changes, but that's OK I'll mark a followup for that.

@Saadnajmi Saadnajmi merged commit 6876a33 into microsoft:main Sep 7, 2022
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Feb 13, 2023
Allow to render a scrollView's content in inverted order which is especially helpful in messaging applications.

We can't rely on -1 scale hacks on macOS because of inverse issues with trackpad/scrollwheel, dragging scrollbars, tracking hovers, etc.

Hence we added 'native' support for inverted views

Co-authored-by: Scott Kyle <[email protected]>
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Mar 10, 2023
Allow to render a scrollView's content in inverted order which is especially helpful in messaging applications.

We can't rely on -1 scale hacks on macOS because of inverse issues with trackpad/scrollwheel, dragging scrollbars, tracking hovers, etc.

Hence we added 'native' support for inverted views

Co-authored-by: Scott Kyle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants