import { LayoutAnimation , Platform , UIManager } from "react-native" ; import { BaseItemAnimator } from "../../../core/ItemAnimator" ; export class DefaultNativeItemAnimator implements BaseItemAnimator { public shouldAnimateOnce : boolean = true ; private _hasAnimatedOnce : boolean = false ; private _isTimerOn : boolean = false ; constructor ( ) { if ( Platform . OS === "android" && UIManager . setLayoutAnimationEnabledExperimental ) { UIManager . setLayoutAnimationEnabledExperimental ( true ) ; } } public animateWillMount ( atX , atY , itemIndex ) { return undefined ; } public animateDidMount ( atX , atY , itemRef , itemIndex ) { } public animateWillUpdate ( fromX , fromY , toX , toY , itemRef , itemIndex ) { this . _hasAnimatedOnce = true ; } public animateShift ( fromX , fromY , toX , toY , itemRef , itemIndex ) { if ( fromX !== toX || fromY !== toY ) { if ( ! this . shouldAnimateOnce || this . shouldAnimateOnce && ! this . _hasAnimatedOnce ) { LayoutAnimation . configureNext ( LayoutAnimation . Presets . easeInEaseOut ) ; this . _hasAnimatedOnce = true ; } } else { if ( ! this . _isTimerOn ) { this . _isTimerOn = true ; if ( ! this . _hasAnimatedOnce ) { setTimeout ( ( ) => { this . _hasAnimatedOnce = true ; } , 1000 ) ; } } } return false ; } public animateWillUnmount ( atX , atY , itemRef , itemIndex ) { } }