0.2.2 • Published 1 year ago

@gemcook/react-native-animated-scroll-view v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-animated-scroll-view

A component that animates the header when the content is scrolled.

example1

Installation

npm install @gemcook/react-native-animated-scroll-view

or yarn

yarn add @gemcook/react-native-animated-scroll-view

Usage

Simple to use

import * as React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { ScrollView } from 'react-native-animated-scroll-view';

const DATA = Array.from({ length: 30 }).map((_, index) => ({ id: index }));
const maxHeaderHeight = 150;
const minHeaderHeight = 50;

export default function App() {
  return (
    <View style={styles.container}>
      <ScrollView
        maxHeaderHeight={maxHeaderHeight}
        minHeaderHeight={minHeaderHeight}
        AnimationHeaderComponent={<View style={styles.animationHeader} />}
      >
        {DATA.map((item) => {
          return (
            <View style={styles.listItem} key={item.id}>
              <Text>{item.id}</Text>
            </View>
          );
        })}
      </ScrollView>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  listItem: {
    width: '100%',
    height: 60,
    justifyContent: 'center',
    alignItems: 'center',
  },
  animationHeader: {
    backgroundColor: 'red',
    height: '100%',
    width: '100%',
  },
});

It can be used not only for ScrollView, but also for FlatList or SectionList

import {
  ScrollView,
  FlatList,
  SectionList,
} from 'react-native-animated-scroll-view';

Props

Each component inherits the Props of the original component

Propstypedescriptionrequireddefault
AnimationHeaderComponentReactNodeAnimationHeader componentfalse--
animationHeaderStyleViewStyleAnimationHeader stylefalse--
maxHeaderHeightnumberHeader maximum heighttrue--
minHeaderHeightnumberHeader minimum heighttrue--
floatingbooleanWhether or not the header should appear immediately when the user scrolls upwardfalsefalse

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.2.2

1 year ago

0.2.1

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago