@@ -50,6 +50,7 @@ export default class SortableList extends Component {
5050 _contentOffset = { x : 0 , y : 0 } ;
5151
5252 state = {
53+ animated : false ,
5354 order : this . props . order || Object . keys ( this . props . data ) ,
5455 rowsLayouts : null ,
5556 containerLayout : null ,
@@ -71,9 +72,9 @@ export default class SortableList extends Component {
7172
7273 if ( data && nextData && ! shallowEqual ( data , nextData ) ) {
7374 uniqueRowKey . id ++ ;
74- this . _areRowsAnimated = false ;
7575 this . _rowsLayouts = [ ] ;
7676 this . setState ( {
77+ animated : false ,
7778 data : nextData ,
7879 containerLayout : null ,
7980 rowsLayouts : null ,
@@ -146,8 +147,9 @@ export default class SortableList extends Component {
146147 }
147148
148149 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 ) } ] )
151153 const innerContainerStyle = [ styles . container ] ;
152154 let { refreshControl} = this . props ;
153155
@@ -164,7 +166,7 @@ export default class SortableList extends Component {
164166 }
165167
166168 return (
167- < View style = { StyleSheet . flatten ( [ containerStyle , { opacity : 1 } ] ) } ref = { this . _onRefContainer } >
169+ < View style = { containerStyle } ref = { this . _onRefContainer } >
168170 < ScrollView
169171 refreshControl = { refreshControl }
170172 ref = { this . _onRefScrollView }
@@ -183,7 +185,7 @@ export default class SortableList extends Component {
183185
184186 _renderRows ( ) {
185187 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 ;
187189
188190 let rowHeight = 0 ;
189191 let rowWidth = 0 ;
@@ -229,7 +231,7 @@ export default class SortableList extends Component {
229231 key = { uniqueRowKey ( key ) }
230232 ref = { this . _onRefRow . bind ( this , key ) }
231233 horizontal = { horizontal }
232- animated = { this . _areRowsAnimated && ! active }
234+ animated = { animated && ! active }
233235 disabled = { ! sortingEnabled }
234236 style = { style }
235237 location = { location }
@@ -270,7 +272,9 @@ export default class SortableList extends Component {
270272 rowsLayouts : rowsLayoutsByKey ,
271273 contentHeight,
272274 contentWidth,
273- } , ( ) => ( this . _areRowsAnimated = true ) ) ;
275+ } , ( ) => {
276+ this . setState ( { animated : true } ) ;
277+ } ) ;
274278 } ) ;
275279 } ) ;
276280 }
0 commit comments