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

[NOT FOR COMMIT] Try if reverting "native animated scroll event support" fixes build #12862

Closed
wants to merge 1 commit into from
Closed
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
42 changes: 5 additions & 37 deletions Examples/UIExplorer/js/FlatListExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
const React = require('react');
const ReactNative = require('react-native');
const {
Animated,
FlatList,
StyleSheet,
View,
Expand All @@ -48,8 +47,6 @@ const {
renderSmallSwitchOption,
} = require('./ListExampleShared');

const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);

const VIEWABILITY_CONFIG = {
minimumViewTime: 3000,
viewAreaCoveragePercentThreshold: 100,
Expand All @@ -69,29 +66,15 @@ class FlatListExample extends React.PureComponent {
logViewable: false,
virtualized: true,
};

_onChangeFilterText = (filterText) => {
this.setState({filterText});
};

_onChangeScrollToIndex = (text) => {
this._listRef.getNode().scrollToIndex({viewPosition: 0.5, index: Number(text)});
this._listRef.scrollToIndex({viewPosition: 0.5, index: Number(text)});
};

_scrollPos = new Animated.Value(0);
_scrollSinkX = Animated.event(
[{nativeEvent: { contentOffset: { x: this._scrollPos } }}],
{useNativeDriver: true},
);
_scrollSinkY = Animated.event(
[{nativeEvent: { contentOffset: { y: this._scrollPos } }}],
{useNativeDriver: true},
);

componentDidUpdate() {
this._listRef.getNode().recordInteraction(); // e.g. flipping logViewable switch
this._listRef.recordInteraction(); // e.g. flipping logViewable switch
}

render() {
const filterRegex = new RegExp(String(this.state.filterText), 'i');
const filter = (item) => (
Expand All @@ -112,6 +95,7 @@ class FlatListExample extends React.PureComponent {
<PlainInput
onChangeText={this._onChangeScrollToIndex}
placeholder="scrollToIndex..."
style={styles.searchTextInput}
/>
</View>
<View style={styles.options}>
Expand All @@ -120,19 +104,10 @@ class FlatListExample extends React.PureComponent {
{renderSmallSwitchOption(this, 'fixedHeight')}
{renderSmallSwitchOption(this, 'logViewable')}
{renderSmallSwitchOption(this, 'debug')}
<Animated.View style={[styles.spindicator, {
transform: [
{rotate: this._scrollPos.interpolate({
inputRange: [0, 5000],
outputRange: ['0deg', '360deg'],
extrapolate: 'extend',
})}
]
}]} />
</View>
</View>
<SeparatorComponent />
<AnimatedFlatList
<FlatList
HeaderComponent={HeaderComponent}
FooterComponent={FooterComponent}
SeparatorComponent={SeparatorComponent}
Expand All @@ -150,7 +125,6 @@ class FlatListExample extends React.PureComponent {
legacyImplementation={false}
numColumns={1}
onRefresh={this._onRefresh}
onScroll={this.state.horizontal ? this._scrollSinkX : this._scrollSinkY}
onViewableItemsChanged={this._onViewableItemsChanged}
ref={this._captureRef}
refreshing={false}
Expand Down Expand Up @@ -206,7 +180,7 @@ class FlatListExample extends React.PureComponent {
}
};
_pressItem = (key: number) => {
this._listRef.getNode().recordInteraction();
this._listRef.recordInteraction();
pressItem(this, key);
};
_listRef: FlatList<*>;
Expand All @@ -222,12 +196,6 @@ const styles = StyleSheet.create({
searchRow: {
paddingHorizontal: 10,
},
spindicator: {
marginLeft: 'auto',
width: 2,
height: 16,
backgroundColor: 'darkgray',
},
});

module.exports = FlatListExample;
9 changes: 0 additions & 9 deletions Libraries/CustomComponents/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

const MetroListView = require('MetroListView'); // Used as a fallback legacy option
const React = require('React');
const ReactNative = require('ReactNative');
const View = require('View');
const VirtualizedList = require('VirtualizedList');

Expand Down Expand Up @@ -236,14 +235,6 @@ class FlatList<ItemT> extends React.PureComponent<DefaultProps, Props<ItemT>, vo
this._listRef.recordInteraction();
}

getScrollableNode() {
if (this._listRef && this._listRef.getScrollableNode) {
return this._listRef.getScrollableNode();
} else {
return ReactNative.findNodeHandle(this._listRef);
}
}

componentWillMount() {
this._checkProps(this.props);
}
Expand Down
12 changes: 1 addition & 11 deletions Libraries/CustomComponents/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

const Batchinator = require('Batchinator');
const React = require('React');
const ReactNative = require('ReactNative');
const RefreshControl = require('RefreshControl');
const ScrollView = require('ScrollView');
const View = require('View');
Expand Down Expand Up @@ -238,14 +237,6 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
this._updateViewableItems(this.props.data);
}

getScrollableNode() {
if (this._scrollRef && this._scrollRef.getScrollableNode) {
return this._scrollRef.getScrollableNode();
} else {
return ReactNative.findNodeHandle(this._scrollRef);
}
}

static defaultProps = {
disableVirtualization: false,
getItem: (data: any, index: number) => data[index],
Expand Down Expand Up @@ -302,8 +293,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
super(props);
invariant(
!props.onScroll || !props.onScroll.__isNative,
'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' +
'to support native onScroll events with useNativeDriver',
'VirtualizedList does not support AnimatedEvent with onScroll and useNativeDriver',
);
this._updateCellsToRenderBatcher = new Batchinator(
this._updateCellsToRender,
Expand Down