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 inverted list by applying forked version of react-native-web #6268

Merged
merged 6 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build/react-native-web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
cd ./node_modules/react-native-web &&
npm install &&
npm run compile &&
rm -rf ./node_modules &&
cd ./packages/react-native-web &&
npm install --only=prod &&
rm -rf ./node_modules/react ./node_modules/react-dom &&
cd ../../ &&
cp -R ./packages/react-native-web/* ./
86 changes: 2 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"license": "MIT",
"private": true,
"scripts": {
"postinstall": "./build/react-native-web.sh",
"android": "npm run check-metro-bundler-port && react-native run-android",
"ios": "npm run check-metro-bundler-port && react-native run-ios",
"ipad": "npm run check-metro-bundler-port && react-native run-ios --simulator=\"iPad Pro (12.9-inch) (4th generation)\"",
Expand Down Expand Up @@ -97,7 +98,7 @@
"react-native-safe-area-context": "^3.1.4",
"react-native-screens": "^3.0.0",
"react-native-svg": "^12.1.0",
"react-native-web": "0.15.7",
"react-native-web": "git+https://github.com/Expensify/react-native-web.git#bfe201af25f9bd465af203b02fc978515b96e956",
"react-pdf": "^5.2.0",
"react-plaid-link": "^3.2.0",
"react-web-config": "^1.0.0",
Expand Down
25 changes: 0 additions & 25 deletions src/components/InvertedFlatList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ const propTypes = {
}).isRequired,
};

// This is adapted from https://codesandbox.io/s/react-native-dsyse
// It's a HACK alert since FlatList has inverted scrolling on web
class InvertedFlatList extends React.Component {
constructor(props) {
super(props);

this.invertedWheelEvent = this.invertedWheelEvent.bind(this);
this.list = undefined;
}

Expand All @@ -30,28 +27,6 @@ class InvertedFlatList extends React.Component {
} else {
this.props.innerRef(this.list);
}

if (this.list) {
this.list
.getScrollableNode()
.addEventListener('wheel', this.invertedWheelEvent);

this.list.setNativeProps({
style: {
transform: 'translate3d(0,0,0) scaleY(-1)',
},
});
}
}

componentWillUnmount() {
this.list.getScrollableNode()
.removeEventListener('wheel', this.invertedWheelEvent);
}

invertedWheelEvent(e) {
this.list.getScrollableNode().scrollTop -= e.deltaY;
e.preventDefault();
}

render() {
Expand Down