0.1.2 • Published 2 years ago

react-native-flatlist-animated v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-flatlist-animated

Animated FlatList component that supports entering, exiting and reordering animations.

Installation

npm i react-native-flatlist-animated

Demo

Supports zoom, fade and slide animations for enterance and exit.

zoom slide

Key Advantages

  • No animation on layout properties (better performance)
  • Handles unmounting and mounting animations
  • Handles list re-ordering
  • Native driver is used in all animations
  • Supports React Native FlatList props
  • JavaScript only implementation
  • Fully typed

Usage

import { Text, View } from "react-native";
import AnimatedFlatList from "react-native-flatlist-animated";

const listData = [
  { key: "item1", value: "ITEM-1" },
  { key: "item2", value: "ITEM-2" },
];

() => (
  <AnimatedFlatList
    data={listData}
    style={{ width: "100%" }}
    itemContainerHeight={50}
    renderItem={({ item, _index }) => (
      <View style={{ width: "100%", height: "100%" }}>
        <Text>{item.value}</Text>
      </View>
    )}
  />
);

Properties

PropertyDescriptionDefault
itemContainerHeightRequired. Height of a single list item.-
enteringOptional. Animation selection for entering phase.zoomIn
exitingOptional. Animation selection for exiting phase.zoomOut
transitionOptional. Animation selection for layout transitions.spring
reorderingOptional. Animation selection for items that are moved up in the list.translateOnly
timingConfigOptional. Animation configuration for transitions. Requires transition="timing".Default timing config in Animated API. Note that below props will be overwritten: toValue: 1, duration: depends, delay: depends, useNativeDriver: true
springConfigOptional. Animation configuration for transitions. Requires transition="spring".Default spring config in Animated API. Note that below props will be overwritten: toValue: 1, delay: depends, useNativeDriver: true
enterDurationOptional. Duration of entering animation in milliseconds.250
exitDurationOptional. Duration of exiting animation in milliseconds.250
horizontalSlideRangeOptional. The initial or final position to be used in sliding type animations.screen width

Examples

Check full example in the Example folder.

  • Click on the items to remove them from the list.
  • Press Add Item to add random entry from the map.
  • Press Delete Item to remove a random entry from the list.
  • Press Reorder Item to pick a random entry and change its position randomly.

Note: The assets used in the example app represent imaginary characters but influenced by real friendship. I have used Aseprite for pixel art.