Socket
Socket
Sign inDemoInstall

react-native-animated-pressable

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-animated-pressable

PressableAnimated PressableAnimated is a React Native UI component that allows you to create pressable elements with an animation. The animation is fully customizable, offering flexibility in its usage. Table of Contents <li>


Version published
Weekly downloads
3
decreased by-87.5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

PressableAnimated

PressableAnimated is a React Native UI component that allows you to create pressable elements with an animation. The animation is fully customizable, offering flexibility in its usage.

Table of Contents

  • Intro
  • Motivation
  • Installation
  • Demo
  • Usage
  • API
  • Example

Intro 🚀

PressableAnimated is not just another UI component; it's a delightful concoction of interactivity, design, and simplicity, crafted meticulously to enhance your React Native apps. It allows developers to harness the power of animations without wrestling with the complexities typically associated with implementing them.

Motivation 🎯

I created PressableAnimated to make animations more accessible to developers. It packages the vibrant world of animations into an easy-to-use component, offering developers a quick and straightforward way to animate pressable elements, all without compromising customization or control.


My hope is that PressableAnimated will help you not only to make your apps more engaging and delightful but also to spark your curiosity to explore and play with animations in your own creative ways. Happy coding!

Installation 💻

Installing PressableAnimated, is a breeze and can be done with either npm or yarn.

npm install react-native-animated-pressable

or

yarn add react-native-animated-pressable

Demo 🎥

Press animation is significantly smoother in reality compared to the gifs presented below.

Example 1

scaleValue={1.2}

Example 1

Example 2

scaleValue={0.8}

Example 2

Usage

First, import the PressableAnimated component in your project.

import { PressableAnimated } from "./src/components/PressableAnimated";

Then wrap the component you want to animate with the PressableAnimated component.

import { PressableAnimated } from "./src/components/PressableAnimated";
import { StyleSheet, Text, View } from "react-native";

export default function App() {
  return (
    <View style={styles.container}>
      <PressableAnimated
        bounce
        customStyles={styles.customStyles}
        scaleValue={1.2}
        onPress={() => {
          console.log("onPress");
        }}
        onPressIn={() => {
          console.log("onPressIn");
        }}
        onPressOut={() => {
          console.log("onPressOut");
        }}
      >
        <Text style={styles.text}>App</Text>
      </PressableAnimated>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
  customStyles: {
    alignItems: "center",
    justifyContent: "center",
    backgroundColor: "#071D38",
    width: 200,
    height: 200,
    borderRadius: 20,
  },
  text: {
    color: "#fff",
    fontSize: 20,
  },
});

API

PressableAnimated accepts the following props:

PropTypeDefaultDescription
scaleValuenumber1.03The value to which the component scales when pressed.
durationnumber500The duration of the scale animation, in milliseconds.
isDisabledbooleanfalseIf true, disables the pressable functionality.
isPressedbooleanfalseManually controls the pressed state of the component.
customStylesStyleProp<ViewStyle>undefinedStyles the Animated View.
onPress() => voidundefinedCallback function invoked when the press is released.
onPressIn() => voidundefinedCallback function invoked when the press is initiated.
onPressOut() => voidundefinedCallback function invoked when the press is released.
childrenReact.ReactNodeundefinedThe components to be rendered inside the PressableAnimated component.

Keywords

FAQs

Last updated on 19 Aug 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc