GithubHelp home page GithubHelp logo

kottidev / react-native-expanding-circle-transition Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexbrillant/react-native-expanding-circle-transition

0.0 2.0 0.0 783 KB

A simple react native component to make an expanding circle transition.

JavaScript 100.00%

react-native-expanding-circle-transition's Introduction

react-native-expanding-circle-transition

contributions welcome Standard - JavaScript Style Guide npm version npm

Preview

App preview

Installation

npm install react-native-expanding-circle-transition --save

Props

Props type description required or default
color string color of the circle view 'orange'
size number size of the circle view when fully expanded the height of the screen times 3
duration number duration of the animation 800
expand bool expand if true, reduce false true
position enum position of the circle : ['topLeft', 'topRight', 'bottomLeft', 'bottomRight', 'center', 'left', 'right', 'top', 'bottom', 'custom'] 'topLeft'
customLeftMargin number custom position's left margin from the center of the circle positioned at topLeft 0
customTopMargin number custom position's top margin from the center of the circle positioned at topLeft 0

How to use

To trigger the animation, you need to use a ref to call the start function of this component. Pass a callback to the start function to change the scene before the circle is hidden(check out usage exemple handlePress function).

Usage exemple

import React, {
  Component
} from 'react'

import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableWithoutFeedback
} from 'react-native'

import CircleTransition from 'react-native-expanding-circle-transition'

export default class Exemples extends Component {
  constructor (props) {
    super(props)
    this.state = {
      oldColor: '#E3E4E5',
      color: 'orange'
    }
    this.handlePress = this.handlePress.bind(this)
  }

  handlePress() {
    this.circleTransition.start(() => {
      this.setState({
        oldColor: this.state.color
      })
    })
  }

  render () {
    let { color, oldColor } = this.state

    return (
      <View style={[styles.container, {
          backgroundColor: oldColor
        }]}>
        <TouchableWithoutFeedback 
          style={styles.touchable} 
          onPress={this.handlePress}>
          <View>
            <Text style={styles.position}>
              Press to start circle transition animation
            </Text>
          </View>
        </TouchableWithoutFeedback>
        <CircleTransition
          ref={(circle) => { this.circleTransition = circle }}
          color={color}
          expand
          position={'center'}
        />
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF'
  },
  position: {
    flex: 1,
    top: 320,
    fontSize: 25,
    alignSelf: 'center',
    fontWeight: '400',
    textAlign: 'center',
    color: '#253039'
  },
  touchable: {
    flex: 1,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center'
  }
})

react-native-expanding-circle-transition's People

Contributors

alexbrillant avatar

Watchers

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