Skip to content

LexRiver/react-ripple

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Ripple

React Component to Make Google Material Design Ripple Effect. It's adopted from angular-ripple

DEMO

Install

You can import react-ripple to your react component file like this and process it with your preprocessor.;

You can install it via NPM

npm install react-ripple-effect

Usage

Usage With Predefined Ripple Button

import React from 'react';
import ReactDOM from 'react-dom';

import { RippleButton } from 'react-ripple-effect';

class App extends React.Component {

  render(){
    return(
      <RippleButton>Click On Me!</RippleButton>
    )
  }

}


ReactDOM.render(<App />, document.getElementById("app"))

Usage Standalone Ripple Component

import React from 'react';

import { Ripple } from 'react-ripple-effect';

class RippleButton extends React.Component {

  constructor() {
    super();
    this.state = {
      cursorPos: {}
    }
  }

  render () {
    return (
      <button
        className="Ripple-parent"
        onMouseUp={ this.handleClick.bind(this) }
        onTouchend={ this.handleClick.bind(this) } >
        { this.props.children }
        <Ripple cursorPos={ this.state.cursorPos } />
      </button>
    )
  }

  handleClick(e){
    // Get Cursor Position
    let cursorPos = {
      top: e.clientY,
      left: e.clientX,
      // Prevent Component duplicates do ripple effect at the same time
      time: Date.now()
    }
    this.setState({ cursorPos: cursorPos })
  }

}

export default RippleButton;

Props

cursorPos (Object)

You need to describe the cursor position ( when parent is clicked ) with the structure like the object bellow

let cursorPos = {
  top: e.clientY,
  left: e.clientX,
  // Prevent Component duplicates do ripple effect at the same time
  time: Date.now()
}

Thank You for Making this useful~

Let's talk about some projects with me

Just Contact Me At:

License

MIT Copyright (c) 2016 - forever Naufal Rabbani

About

React Component to Make Google Material Design Ripple Effect. http://bosnaufal.github.io/react-ripple/

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 53.8%
  • JavaScript 24.6%
  • CSS 21.6%