New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-native-animated-bottom-drawer

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-animated-bottom-drawer

A lightweight, highly performant and animated bottom drawer for react native

latest
Source
npmnpm
Version
0.0.23
Version published
Maintainers
1
Created
Source

React Native Animated Bottom Drawer

A lightweight and highly performant bottom drawer for react native

Features

  • Extremely lightweight (~20 KB) and highly performant
  • Support for snapping (multi height bottom drawer)
  • Smooth Animations and Gestures
  • Completely Customisable
  • Automatic Keyboard Handling
  • useBottomDrawer hook to allow the bottom drawer child components to access bottom drawer methods
  • Written in Typescript

Installation

using npm

npm i react-native-animated-bottom-drawer

using yarn

yarn add react-native-animated-bottom-drawer

Usage

import React, {useRef} from 'react';
import {View, Text, StyleSheet, Button, SafeAreaView} from 'react-native';
import BottomDrawer, {
  BottomDrawerMethods,
} from 'react-native-animated-bottom-drawer';

const App = () => {
  // ref
  const bottomDrawerRef = useRef<BottomDrawerMethods>(null);

  // renders
  return (
    <SafeAreaView style={styles.container}>
      <Button title="Open" onPress={() => bottomDrawerRef.current.open()} />
      <BottomDrawer ref={bottomDrawerRef} openOnMount>
        <View style={styles.contentContainer}>
          <Text>Awesome 🎉</Text>
        </View>
      </BottomDrawer>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 24,
  },
  contentContainer: {
    flex: 1,
    alignItems: 'center',
  },
});

export default App;

Available Props

NameTypeDefaultDescriptionRequired
gestureModehandle content nonehandleThis prop determines where to apply the gesturesNo
openDurationnumber450Animation duration when the bottom drawer is openedNo
closeDurationnumber300Animation duration when the bottom drawer is closedNo
onOpenfunctionnullCallback function when the bottom drawer is openedNo
onClosefunctionnullCallback function when the bottom drawer is closedNo
onBackdropPressfunctiontrueCallback function when the backdrop is pressedNo
onBackPressfunctionnullCallback function when the hardware back button is pressedNo
closeOnPressBackbooleantrueSetting this true will allow the bottom drawer to close when hardware back is pressed (only on android)No
closeOnBackdropPressbooleantrueSetting this true will allow the bottom drawer to close when backdrop is pressedNo
openOnMountbooleanfalseSetting this true will automatically open the bottom drawer when the parent component is mountedNo
enableSnappingbooleanfalseSet this to true when you want to snap the bottom drawer to multiple heightsNo
snapPointsnumber[][400]Points for the bottom sheet to snap to, points should be sorted from bottom to top. It accepts array of number. Example: [300, 500, 700]Yes, if enableSnapping is true
backdropColorstring#000Color of the backdropNo
backdropOpacitynumber0.5Opacity of the backdropNo
customStylesobject{}Add your custom styles here!No
overDragbooleantrueSetting this true will allow the bottom sheet to be overdraggedNo
initialIndexnumber0The initial index out of snapPoints when the bottom sheet is openedNo
initialHeightnumber420The initial height of the bottom sheet when opened. Note: This prop is not available when enableSnapping is set to trueNo
safeTopOffsetnumber50Minimum safe distance from top while dragging the sheet or keyboard is openedNo

Available Methods

These methods can be accessed by bottom drawer reference or useBottomDrawer hook.

open

Opens the bottom drawer

type open = (
  // open at provided sheetHeight
  sheetHeight?: number,
) => void;

NOTE: sheetHeight is only read when enableSnapping is set to false. If enableSnapping is true, then the bottom sheet will be opened at index 0 out of snapPoints.

close

Closes the bottom drawer

type close = () => void;

snapToPosition

Snaps the bottom drawer to given position

type snapToPosition = (
  sheetHeight: number,
  config?: {
    resetLastPosition?: boolean;
  },
) => void;

snapToIndex

Snaps the bottom drawer to given index out of snapPoints (requires enableSnapping to be true)

type snapToIndex = (index: number) => void;

NOTE: This method is only accessible when enableSnapping is set to true.

Keywords

react native

FAQs

Package last updated on 11 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts