@@ -50,6 +50,7 @@ export default class SortableList extends Component {
50
50
_contentOffset = { x : 0 , y : 0 } ;
51
51
52
52
state = {
53
+ animated : false ,
53
54
order : this . props . order || Object . keys ( this . props . data ) ,
54
55
rowsLayouts : null ,
55
56
containerLayout : null ,
@@ -71,9 +72,9 @@ export default class SortableList extends Component {
71
72
72
73
if ( data && nextData && ! shallowEqual ( data , nextData ) ) {
73
74
uniqueRowKey . id ++ ;
74
- this . _areRowsAnimated = false ;
75
75
this . _rowsLayouts = [ ] ;
76
76
this . setState ( {
77
+ animated : false ,
77
78
data : nextData ,
78
79
containerLayout : null ,
79
80
rowsLayouts : null ,
@@ -146,8 +147,9 @@ export default class SortableList extends Component {
146
147
}
147
148
148
149
render ( ) {
149
- const { contentContainerStyle, horizontal, style : containerStyle } = this . props ;
150
- const { contentHeight, contentWidth, scrollEnabled} = this . state ;
150
+ const { contentContainerStyle, horizontal, style} = this . props ;
151
+ const { animated, contentHeight, contentWidth, scrollEnabled} = this . state ;
152
+ const containerStyle = StyleSheet . flatten ( [ style , { opacity : Number ( animated ) } ] )
151
153
const innerContainerStyle = [ styles . container ] ;
152
154
let { refreshControl} = this . props ;
153
155
@@ -164,7 +166,7 @@ export default class SortableList extends Component {
164
166
}
165
167
166
168
return (
167
- < View style = { StyleSheet . flatten ( [ containerStyle , { opacity : 1 } ] ) } ref = { this . _onRefContainer } >
169
+ < View style = { containerStyle } ref = { this . _onRefContainer } >
168
170
< ScrollView
169
171
refreshControl = { refreshControl }
170
172
ref = { this . _onRefScrollView }
@@ -183,7 +185,7 @@ export default class SortableList extends Component {
183
185
184
186
_renderRows ( ) {
185
187
const { horizontal, sortingEnabled, renderRow} = this . props ;
186
- const { order, data, activeRowKey, releasedRowKey, rowsLayouts} = this . state ;
188
+ const { animated , order, data, activeRowKey, releasedRowKey, rowsLayouts} = this . state ;
187
189
188
190
let rowHeight = 0 ;
189
191
let rowWidth = 0 ;
@@ -229,7 +231,7 @@ export default class SortableList extends Component {
229
231
key = { uniqueRowKey ( key ) }
230
232
ref = { this . _onRefRow . bind ( this , key ) }
231
233
horizontal = { horizontal }
232
- animated = { this . _areRowsAnimated && ! active }
234
+ animated = { animated && ! active }
233
235
disabled = { ! sortingEnabled }
234
236
style = { style }
235
237
location = { location }
@@ -270,7 +272,9 @@ export default class SortableList extends Component {
270
272
rowsLayouts : rowsLayoutsByKey ,
271
273
contentHeight,
272
274
contentWidth,
273
- } , ( ) => ( this . _areRowsAnimated = true ) ) ;
275
+ } , ( ) => {
276
+ this . setState ( { animated : true } ) ;
277
+ } ) ;
274
278
} ) ;
275
279
} ) ;
276
280
}
0 commit comments