Git Product home page Git Product logo

react-native-collapsible-header-views's Introduction

react-native-collapsible-header-views

npm version CircleCI js-standard-style Dependency Status devDependencies Status typings included npm

ScrollView, FlatList, SectionList with collapsible headers + HOC for wrapping custom scrollables

Getting started

$ npm install react-native-collapsible-header-views --save

Demo

Android iOS

Example

import * as React from 'react';
import { View, Platform } from 'react-native';
import { CollapsibleHeaderScrollView } from 'react-native-collapsible-header-views';

export const Basic = () => (
  <CollapsibleHeaderScrollView
    CollapsibleHeaderComponent={<View style={{ backgroundColor: 'white' }} />}
    headerHeight={100}
    statusBarHeight={Platform.OS === 'ios' ? 20 : 0}
  >
    <View style={{ height: 2000, backgroundColor: 'wheat' }} />
  </CollapsibleHeaderScrollView>
);

Description

Library exports three components CollapsibleHeaderScrollView, CollapsibleHeaderFlatList, CollapsibleHeaderSectionList and a HOC withCollapsibleHeader for wrapping custom scrollable components. Provided components support all props and instance methods of corresponding wrapped components. Note that components are also wrapped with Animated.createAnimatedComponent under the hood.

Reference

Props

CollapsibleHeaderScrollViewProps, CollapsibleHeaderFlatListProps, CollapsibleHeaderSectionListProps

  • CollapsibleHeaderComponent: React.ReactElement<unknown> | React.ComponentType<CollapsibleHeaderProps> - React element or component/function that receives CollapsibleHeaderProps object. Required;
  • headerHeight: number - height of CollapsibleHeaderComponent. Required;
  • statusBarHeight?: number - height of status bar. Defaults to 0;
  • headerContainerBackgroundColor?: string - background color for CollapsibleHeaderComponent and status bar container. Defaults to 'white';
  • disableHeaderSnap?: boolean - pass true to disable header snap animations. Defaults to false;
  • headerAnimationDuration?: number - duration of snap and showHeader, hideHeader animations. Defaults to 350;
  • clipHeader?: boolean - if true header will be clipped with overflow: 'hidden' style.

Also some of ScrollView props have new defaults: bounces defaults to false, overScrollMode to 'never' and scrollEventThrottle to 1.

CollapsibleHeaderProps

  • interpolatedHeaderTranslation: (from: number, to: number) => Animated.AnimatedInterpolation - creates new AnimatedInterpolation object, whose input range corresponds to header translation and output range is specified by from and to params. Can be used for custom animations, like setting opacity etc.;
  • showHeader: (options: { animated: boolean } | unknown) => void - pushes header down with animation enabled by default;
  • hideHeader: (options: { animated: boolean } | unknown) => void - pulls header up with animation enabled by default.

Methods

CollapsibleHeaderScrollView, CollapsibleHeaderFlatList, CollapsibleHeaderSectionList

  • animatedComponent: () => any | null - returns result of Animated.createAnimatedComponent applied to original component;
  • showHeader: (options: { animated: boolean } | unknown) => void - pushes header down with animation enabled by default;
  • hideHeader: (options: { animated: boolean } | unknown) => void - pulls header up with animation enabled by default.

withCollapsibleHeader

  • function withCollapsibleHeader<T extends ScrollViewProps>(Component: React.ComponentClass<T>): React.ComponentClass<CollapsibleHeaderViewProps<T>> - creates new component with collapsible header, it is assumed that input component has all of ScrollView props.

Credits

react-native-collapsible-header-views's People

Contributors

iyegoroff avatar muhamad-rizki avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.