Giter Site home page Giter Site logo

gabimoncha / react-native-pressable-opacity Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrousavy/react-native-pressable-opacity

1.0 0.0 0.0 1.27 MB

A <PressableOpacity> and a supercharged <NativePressableOpacity> components for React Native

License: MIT License

TypeScript 100.00%

react-native-pressable-opacity's Introduction

A Pressable that lowers opacity when pressed.

npm i react-native-pressable-opacity



<PressableOpacity>

A component for responding to touches using the new JS Pressability API.

<PressableOpacity onPress={onBuyPressed} style={styles.buyButton}>
  <Text>Buy this Product</Text>
</PressableOpacity>

The following props are supported:

Name Type Explanation Required Default Value
disabledOpacity number The opacity to use when the disabled prop is true. Use 1 to disable opacity changes when disabling the <PressableOpacity> 0.3
activeOpacity number The opacity to use when the <PressableOpacity> is in a pressed state. 0.2
All Pressable props PressableProps All properties from the React Native Pressable such as onPress, children or disabled. {}

<NativePressableOpacity>

A supercharged <PressableOpacity>.

Requires react-native-gesture-handler and react-native-reanimated (v2)

A component for responding to touches using the native TapGestureHandler without ever going over the JS Bridge. Use this component if you want your Pressables to be able to receive touches, respond to touches, show visual animated feedback (opacity change) and dispatch a callback to JS without using the React Native Thread at all. This component will always be pressable, even when the React Native (JS) Thread freezes because of a heavy JS computation.

⚠️ Warning: This does not work in Modals on Android devices. See software-mansion/react-native-gesture-handler issue #139

<NativePressableOpacity onPress={onBuyPressed} style={styles.buyButton}>
  <Text>Buy this Product</Text>
</NativePressableOpacity>

The following props are supported:

Name Type Explanation Required Default Value
onPress () => void The event to fire after the <PressableOpacity> has been pressed by the user. undefined
activeOpacity number The opacity to use when the <PressableOpacity> is in a pressed state. Changes to and from this opacity will always be animated using a short linear timing animation. 0.2
isInList boolean A flag indicating whether this <PressableOpacity> is rendered in a ScrollView, FlatList or any other component that uses a swipe gesture. This will delay the animation for 50ms so swipe gestures don't immediately trigger opacity changes false
disabled boolean A flag indicating whether this <PressableOpacity> should be disabled and therefore stop receiving touch events. false
ref React.RefObject<TapGestureHandler> A reference to the <TapGestureHandler> component. false
All View props ViewProps All properties from the React Native View component such as style or children. {}
All WithTimingConfig props WithTimingConfig All properties from the react-native-reanimated withTiming options parameter such as Easing or duration. { duration: 50, easing: Easing.linear }

Also try

react-native-pressable-opacity's People

Contributors

mrousavy avatar gabimoncha avatar

Stargazers

Roman 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.