Code Monkey home page Code Monkey logo

react-native-waveview's Introduction

WaveView for React-Native

npm npm

SHOWCASE

Ball

Rectangle

DEPENDENCIES

INSTALL

  1. Install react-native-svg, use

    npm install --save react-native-svg or

    yarn add react-native-svg

  2. Link react-native-svg, check here for help.

  3. npm install --save react-native-waveview or yarn add react-native-waveview

USAGE

Props

name type desc
H number BaseLine height
animated bool animation when mounted
waveParams Array [{ A, T, fill}, ...]
easing string name of easing from ReactNative#Easing
speed number base duration in ms of one wave cycle
speedIncreasePerWave number increase in speed in ms per each wave
/**
  ---------+------------------------+
  <-- P -->|<--    T    -->|        |______
           |   /\          |   /\   |  ^
           |  /  \         |  /  \  |  A
           | /    \        | /    \ |  |
           |/      \       |/      \|__V___
           |        \      /        |  ^
           |         \    /         |  |
           |          \  /          |  |
           |           \/           |  H
           |                        |  |
           |        fill            |  |
  ---------+------------------------+__V___
*/

Methods

  • setWaveParams(waveParams)

  • setWaterHeight(H)

  • startAnim

  • stopAnim

Example

<View style={_styles.container} >
    <TouchableHighlight onPress={()=>{
        // Stop Animation
        this._waveRect && this._waveRect.stopAnim();

        // set water baseline height
        this._waveRect && this._waveRect.setWaterHeight(70);

        // reset wave effect
        this._waveRect && this._waveRect.setWaveParams([
            {A: 10, T: 180, fill: '#FF9F2E'},
            {A: 15, T: 140, fill: '#F08200'},
            {A: 20, T: 100, fill: '#B36100'},
        ]);
    }}>
    <Wave
        ref={ref=>this._waveRect = ref}
        style={_styles.wave}
        H={30}
        waveParams={[
            {A: 10, T: 180, fill: '#62c2ff'},
            {A: 15, T: 140, fill: '#0087dc'},
            {A: 20, T: 100, fill: '#1aa7ff'},
        ]}
        animated={true}
    />
    </TouchableHighlight>
</View>
<View style={_styles.container} >
    <Wave
        style={_styles.waveBall}
        H={70}
        waveParams={[
            {A: 10, T: 180, fill: '#62c2ff'},
            {A: 15, T: 140, fill: '#0087dc'},
            {A: 20, T: 100, fill: '#1aa7ff'},
        ]}
        animated={true}
    />
</View>
const _styles = StyleSheet.create({
    container: {
        flex: 1,
        marginVertical: 10,
        marginHorizontal: 20,
        justifyContent: 'center',
        alignItems: 'center',
        borderWidth: StyleSheet.hairlineWidth,
    },
    wave: {
        width: 100,
        aspectRatio: 1,
        overflow: 'hidden',
        backgroundColor: 'white',
    },
    waveBall: {
        width: 100,
        aspectRatio: 1,
        borderRadius: 50,
        overflow: 'hidden',
    }
});

react-native-waveview's People

Contributors

cubesugar avatar harunsmrkovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-waveview's Issues

Change Wave Direction?

Hello,

I would like to know if it is possible to change the wave's movement direction?

Left to Right instead of Right to left

Thank you

ReadMe

Can you show full example code to apply this library? Im so confuse with the object waveRect.

When param H changed the wave height not changed

It's good only if I call setWaterHeightfunction in ref callback.

                    <Wave ref={(wave) => wave && wave.setWaterHeight(150 * score / scoreTotal)}
                        style={{ width: 150, aspectRatio: 1, overflow: 'hidden', backgroundColor: '#FEB25780', borderRadius: 75 }}
                        H={150 * score / scoreTotal} animated={true} waveParams={[
                            { A: 10, T: 180, fill: '#FEB25780' },
                            { A: 10, T: 180, fill: '#FEB25780' },
                            { A: 10, T: 180, fill: '#FEB25780' },
                        ]}
                    />

v2.0.0 plan

v2.0.0 PLAN

  • ๐ŸŽจ Redesign component - โœ…

    • โšก๏ธ Wave

    • โœจ WaveBackground

    • โœจ Tide

  • ๐Ÿท Written in typescript - โœ…

  • ๐Ÿ“ Document / API Ref

  • ๐Ÿ’ก Example

How to add a label in the middle of the wave?

Hi there, I'm new to react native, what I want to do in my project is I would like to make the button with a background of water wave, is there any suggestion to make it? Or is there any way to add a label in the middle of the water wave?

Abnormal rendring

if i set width of wave to 250 (in my case) then after 3sec waves end and show white background and after almost half sec starts new wave,

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.