Giter VIP home page Giter VIP logo

react-native-css-transition's Introduction

react-native-css-transition

Enable animate react-native components like css transition property.

Install

npm install react-native-css-transition
import Transition from 'react-native-css-transition';

Dependencies

react-native-styling: For compling nested raw style sheet.

Basic usage

Preparing style sheet

It's not a must to use react-native-styling for compling sheet, but we recommended for improving performance.

export const styles = {
    Counter:{
        stateTest: {
            default: {
                transition:[{    //Must not pass to native StyleSheet.create directly, will cause error
                    property:"color",
                    duration:1000,
                    delay:0,
                    timingFunction:Easing.back, // native Easing options
                    interpolate:{   // Default interpolate option for non-numeric value, auto generated
                            inputRange: [0, 100],
                            outputRange: ["#333", "#333"] // Default is initial value
                    },
                    sequence:0, //determinate the property animation effect run sync/async with others, default all zero  
                },{
                    property:"fontSize",
                    duration:1000,
                    delay:0,
                    timingFunction:Easing.back,
                    sequence:1,
                }],
                color: '#333'
            },
            1:{
                color: 'yellow'
            },
            2:{
                color: 'orange'
            },
            3:{
                color: 'red'
            }
        }
    }
};

export const compliedStyle = CreateNestedStyleSheet(styles);

Component

Supports the same basic components as react native Animated: Text, View, ScrollView, Image

<Transition.Text 
  style={GetStyle(compliedStyle.Counter.stateTest,{fontSize:10+stateValue*5},stateValue)} //will change as stateValue changed
  animationOptions={{_all:{useNativeDriver:true}}}
  >{v}</Transition.Text>

Props

style

Can be a normal style ID(s) or raw style properties, or stated sheet by CreateNestedStyleSheet with transition property. The transition component will monitor the delegated properties accroding to transition property setting and animated them on changed. Just like how CSS transition property works.

animationPlayed

Callback on animation played, work as Animation.start(animationPlayed).

animationOptions

Animation option object. First level key match with animated property name, _all to match all. These options will overwrite computed property value.

react-native-css-transition's People

Contributors

dkishere avatar justforfront avatar

Watchers

James Cloos 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.