skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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


  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search