Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pietile-native-kit/fade-view

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pietile-native-kit/fade-view

View that changes content gracefully

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

FadeView

npm version install size

Changes content with FadeOut-FadeIn animation. FadeView uses data prop to know when start the transition. Useful in situations when you want to change content smoothly, implementing tabs content for example.

Installation

Using yarn

yarn add @pietile-native-kit/fade-view

or using npm

npm install -S @pietile-native-kit/fade-view

Usage

Wrap the content in FadeView and set data to value that controls content. Every time data changes FadeView will remember children, play FadeOut animation and then FadeIn with current children already. So it's important to notice that FadeView passthrough children all the time except when playing FadeOut.

Code example

import React, { Component } from 'react';

import { StyleSheet, Text, TouchableOpacity } from 'react-native';
import { FadeView } from '@pietile-native-kit/fade-view';

class FadeViewExample extends Component {
  state = { isCat: true };

  onPress = () => this.setState(({ isCat }) => ({ isCat: !isCat }));

  render() {
    const { isCat } = this.state;

    return (
      <FadeView style={styles.container} data={isCat}>
        <TouchableOpacity
          style={[styles.touchable, { backgroundColor: isCat ? '#c4c' : '#bfb' }]}
          onPress={this.onPress}
        >
          <Text style={styles.text}>{isCat ? '🐱' : '🐶'}</Text>
        </TouchableOpacity>
      </FadeView>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    ...StyleSheet.absoluteFillObject,
    justifyContent: 'center',
    alignItems: 'center',
  },
  touchable: {
    borderRadius: 16,
    padding: 16,
  },
  text: {
    fontSize: 86,
  },
});

export default FadeViewExample;

API

Properties

namedescriptiontypedefault
childrenContentNode-
dataMarker property for telling the FadeView to do FadeOut-FadeInany-
durationHide and show animations durationnumber150
styleStyle of componentstyle-

License

Pietile FadeView is MIT License.

Keywords

FAQs

Package last updated on 02 Aug 2022

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc