0

I've been trying to implement LayoutAnimation to animate the insertion and deletion of items from scrollView. I've added the below code for the same.

import { LayoutAnimation, NativeModules } from 'react-native';

// Animation setup for android
const { UIManager } = NativeModules;
UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);

to set the layout animation

// Animate the add or removal of shortlisted Rail
  useEffect(
    () => LayoutAnimation.configureNext({ ...LayoutAnimation.Presets.easeInEaseOut, duration: 500 }),
    [shortlistItems],
  );

Can anyone help me with this? why is this not working in android?

I've been following this documentation : https://reactnative.dev/docs/layoutanimation

NB : This works great in iOS without any issue.

AMAL MOHAN N
  • 1,416
  • 2
  • 14
  • 26

2 Answers2

0

I used Reanimated to overcome this. Now the application works really great.

REF 1 : https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/layout_animations/

REF 2 : https://youtu.be/6UXfS6FI674

AMAL MOHAN N
  • 1,416
  • 2
  • 14
  • 26
0

I found the code mentioned here works better on Android:

https://github.com/facebook/react-native/issues/13207

 LayoutAnimation.configureNext({
      duration: 300,
      create: {
        type: LayoutAnimation.Types.easeInEaseOut,
        property: LayoutAnimation.Properties.opacity,
      },
      update: { type: LayoutAnimation.Types.easeInEaseOut },
    });

Apparently there is some issue with the delete animation

Lloyd Rajoo
  • 137
  • 2
  • 13