npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-js-only-modal

v1.0.8

Published

An enhanced, animated, customizable Modal for React Native. This is a javascript only Modal

Downloads

18

Readme

react-native-js-only-modal

If you are new to react-native you will find that react-native already has a Modal component that you could already use.

Now the different between this and what react-native already have is that, first this is only js library, it dose not use any native code and also dose not reuse react-native Modal component like other libraries.

Which make it much faster at rendering and easier to customize.

Features

Smooth enter/exit animations Plain simple and flexible APIs Customizable backdrop styling Listeners for the modal animations start and ending Resize itself correctly on device rotation

Setup

The library available at npm install react-native-js-only-modal

Snack Example

react-native-js-only-modal

usage

Since react-native-js-only-modal dose not include any native code and use only js then you need it to be able to reach the root of the app.

In APP components add the Provider around the whole component

  1. import { Provider } from 'react-native-js-only-modal';
import { Provider } from 'react-native-js-only-modal';
const App =()=> {
return (
 <Provider>
  ...Your components here
 </Provider>
)
}
  1. Create a component and nest its content inside of it
import { Modal } from 'react-native-js-only-modal';
 
function WrapperComponent() {
 // show the Modal by setting `visible` = true
 const [visible, setVisible] = React.useState(true);
  return (
    <View>
      <Modal visible={visible}>
        <View style={{ flex: 1 }}>
          <Text>I am the modal content!</Text>
        </View>
      </Modal>
    </View>
  );
}

The visible prop is the only prop you'll really need to make the modal work: you should control this prop value by saving it in your wrapper component state and setting it to true or false when needed.

Modal already has transparent background so by setting style you can customize it however you like.

Available props

Name | Type | Default | Description| | ------------- | ------------- | ------------- | ------------- | | visible | boolean | REQUIRED | Show the modal? | | onCloseRequest | Function | undefined | Triggered when the backdrop gets clicked/swaped | | hideBackDrop | boolean | false | Do not show backdrop | | backDropStyle | StyleProp<ViewStyle> | undefined | override the default style, eg opacity, backgroundColor | | style | StyleProp<ViewStyle> | undefined | Modal Content Style | | containerStyle | StyleProp<ViewStyle> | undefined | The Modal wrapper style, You can specify the position of the content by for example add justifyContent: "flex-start" to make the Modal apear at the top. Also If you have any issue with the height of the modal you could specify maxHeight and minHeight here | | easing | string | "ease" | Timing function for the animation. Valid values: linear, ease, ease-in, ease-out, ease-in-out, ease-in-cubic, ease-out-cubic, ease-in-out-cubic, ease-in-circ, ease-out-circ, ease-in-out-circ, ease-in-expo, ease-out-expo, ease-in-out-expo, ease-in-quad, ease-out-quad, ease-in-out-quad, ease-in-quart, ease-out-quart, ease-in-out-quart, ease-in-quint, ease-out-quint, ease-in-out-quint, ease-in-sine, ease-out-sine, ease-in-out-sine, ease-in-back, ease-out-back, ease-in-out-back. See react-native-animatable for more info | | animationIn | string | "slideInDown" | Specify the animation when the Modal appear eg visible= true see react-native-animatable for other animations | | animationOut | string | "slideOutUp" | Specify the animation when the Modal disappear eg visible= false see react-native-animatable for other animations | | direction | string | "normal" | Direction of animation, especially useful for repeating animations. Valid values: normal, reverse, alternate, alternate-reverse. | | duration | number | 100 | For how long the animation will run (milliseconds). | | onAnimationBegin | Function | undefined | A function that is called when the animation has been started. | | onAnimationEnd | Function | undefined | A function that is called when the animation has been completed successfully or cancelled. Function is called with an endState argument, refer to endState.finished to see if the animation completed or not. | | useNativeDriver | boolean | false | Whether to use native or JavaScript animation driver. Native driver can help with performance but cannot handle all types of styling. | | dimensions | string | "window" | The library gets the Dimensions by screen or window. This is useFull when using FullScreen mode so that the backdrop takes all the screen. When using react-native-web is best to use window instead of screen | | disableBackHandler | boolean | false | When clicking mobile back button onCloseRequest will be called if specified |

Available animations

I am using react-native-animatable for animations, so you can see there what animation it offers.

More than one Modal

When viewing more than one Modal it works that the last visible Modal gets on top of all other Modal.

And this is done by specifing the zIndex

zIndex default start value is 90000 you can increase or decrease this value by specifying zIndex for Provider

Style size

Settings Modal style height,width,minWidth,minHeight to %, will be calculated based on screen or window size

ScrollView

Modal dose not containe ScrollView so you have to add it if you want to use any.