Skip to content

Commit 081560a

Browse files
George Lugitim
authored andcommitted
Remove opacity animation upon mounting and updating (#44)
* removed opacity animation * fix container style * remove animation callbacks
1 parent 0f24227 commit 081560a

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

src/SortableList.js

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ export default class SortableList extends Component {
5757
activeRowIndex: null,
5858
releasedRowKey: null,
5959
sortingEnabled: this.props.sortingEnabled,
60-
scrollEnabled: this.props.scrollEnabled,
61-
style: {
62-
opacity: new Animated.Value(0),
63-
},
60+
scrollEnabled: this.props.scrollEnabled
6461
};
6562

6663
componentDidMount() {
@@ -72,16 +69,14 @@ export default class SortableList extends Component {
7269
const {data: nextData, order: nextOrder} = nextProps;
7370

7471
if (data && nextData && !shallowEqual(data, nextData)) {
75-
this._animateRowsDisappearance(() => {
76-
uniqueRowKey.id++;
77-
this._areRowsAnimated = false;
78-
this._rowsLayouts = [];
79-
this.setState({
80-
data: nextData,
81-
containerLayout: null,
82-
rowsLayouts: null,
83-
order: nextOrder || Object.keys(nextData)
84-
});
72+
uniqueRowKey.id++;
73+
this._areRowsAnimated = false;
74+
this._rowsLayouts = [];
75+
this.setState({
76+
data: nextData,
77+
containerLayout: null,
78+
rowsLayouts: null,
79+
order: nextOrder || Object.keys(nextData)
8580
});
8681

8782
} else if (order && nextOrder && !shallowEqual(order, nextOrder)) {
@@ -150,9 +145,8 @@ export default class SortableList extends Component {
150145
}
151146

152147
render() {
153-
const {contentContainerStyle, horizontal} = this.props;
148+
const {contentContainerStyle, horizontal, style: containerStyle} = this.props;
154149
const {contentHeight, contentWidth, scrollEnabled} = this.state;
155-
const containerStyle = StyleSheet.flatten([this.props.style, this.state.style]);
156150
const innerContainerStyle = [styles.container];
157151

158152
if (horizontal) {
@@ -267,25 +261,11 @@ export default class SortableList extends Component {
267261
rowsLayouts: rowsLayoutsByKey,
268262
contentHeight,
269263
contentWidth,
270-
}, () => {
271-
this._animateRowsAppearance(() => (this._areRowsAnimated = true));
272-
});
264+
}, () => (this._areRowsAnimated = true));
273265
});
274266
});
275267
}
276268

277-
_animateRowsAppearance(onAnimationEnd) {
278-
Animated.timing(this.state.style.opacity, {
279-
toValue: 1,
280-
}).start(onAnimationEnd);
281-
}
282-
283-
_animateRowsDisappearance(onAnimationEnd) {
284-
Animated.timing(this.state.style.opacity, {
285-
toValue: 0,
286-
}).start(onAnimationEnd);
287-
}
288-
289269
_scroll(animated) {
290270
this._scrollView.scrollTo({...this._contentOffset, animated});
291271
}

0 commit comments

Comments
 (0)