├── LICENSE ├── README.md ├── _config.yml └── display.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Joel Arvidsson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-display 2 | This module brings "Display: none" (css style) to turn on/off components from render. Using this module will improve your app performance and appearance with the enter/exit animations. 3 | 4 | ![intro](https://cloud.githubusercontent.com/assets/9949238/22396351/f1452940-e55f-11e6-8e9b-ae26396c2051.gif) 5 | 6 | ## Installation 7 | 8 | `$ npm install react-native-display --save` 9 | 10 | ## Dependencies 11 | [`react-native-animatable`](https://github.com/oblador/react-native-animatable) 12 | 13 | ## Usage 14 | ```js 15 | import Display from 'react-native-display'; 16 | ``` 17 | ### Then, easy as: 18 | ```js 19 | 20 | My custom components 21 | 22 | ``` 23 | 24 | ## Properties 25 | #### ***`enter/exit`*** props using [react-native-animatable](https://github.com/oblador/react-native-animatable) for animation name. 26 | | Prop | Description | Default | 27 | |---|---|---| 28 | |**`enable`**|`true` to render. `false` to not render. |`true`| 29 | |**`defaultDuration`**|Default duration for enter and exit animations. |`250`| 30 | |**`enterDuration`**|Duration for enter animation. |`250`| 31 | |**`exitDuration`**|Duration for exit animation. |`250`| 32 | |**`enter`**|Animation name to run when render (***enable=true***).
Example: ***enter='fadeIn'*** |None| 33 | |**`exit`**|Animation name to run when not render (***enable=false***).
Example: ***exit='fadeOut'*** |None| 34 | |**`style`**|Same *react-native* style for `View`. |None| 35 | |**`keepAlive`**|When ***enable=false***
If `true` components will hide only ([`componentWillUnmount()`](https://facebook.github.io/react/docs/react-component.html#componentwillunmount) will not fire).
If `false` components will not render at all. Use it on complex components or on modules that required init on everytime that they are mount (for example: [react-native-camera](https://github.com/lwansbrough/react-native-camera)). |`false`| 36 | 37 | ### Using inspector to validate that after exit animation component will not render: 38 | 39 | ![demo2](https://cloud.githubusercontent.com/assets/9949238/22395957/8bde370e-e555-11e6-8440-38b85c7c284c.gif) 40 | 41 | ## Full example: 42 | ```js 43 | import React, { Component } from 'react'; 44 | import { 45 | AppRegistry, 46 | StyleSheet, 47 | Text, 48 | View, 49 | Button, 50 | } from 'react-native'; 51 | 52 | import Display from 'react-native-display'; 53 | 54 | export default class testdisplay extends Component { 55 | constructor(props) { 56 | super(props); 57 | 58 | this.state = {enable: true}; 59 | } 60 | 61 | toggleDisplay() { 62 | let toggle = !this.state.enable; 63 | this.setState({enable: toggle}); 64 | } 65 | 66 | render() { 67 | return ( 68 | 69 | 70 |