From bea3f5e5ce95a5057a907988f0fc377c92307a27 Mon Sep 17 00:00:00 2001 From: RoCky Wu Date: Sat, 28 Jan 2017 09:51:30 +0800 Subject: [PATCH] Clean the core --- src/index.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/index.js b/src/index.js index bc72ad9..309e9ac 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import React, {PropTypes} from 'react' +import React, { PropTypes } from 'react' const rippleStyle = { position: 'absolute', @@ -29,15 +29,18 @@ class Ripples extends React.Component { state = { rippleStyle: {}, - wrapStyle: {} } handleClick = (ev) => { ev.stopPropagation() - const {onClick, color, during} = this.props - const {pageX, pageY, currentTarget: {offsetLeft, offsetTop, - offsetWidth, offsetHeight}} = ev + const { onClick, color, during } = this.props + const { + pageX, pageY, currentTarget: { + offsetLeft, offsetTop, + offsetWidth, offsetHeight + } + } = ev const left = pageX - offsetLeft const top = pageY - offsetTop @@ -50,13 +53,13 @@ class Ripples extends React.Component { } }) - setTimeout(()=> { + setTimeout(() => { const size = Math.max(offsetWidth, offsetHeight) this.setState({ rippleStyle: { left, top, - transform: `${rippleStyle.transform} scale(${size/9})`, + transform: `${rippleStyle.transform} scale(${size / 9})`, opacity: 0, transition: `all ${during}ms`, } @@ -67,21 +70,19 @@ class Ripples extends React.Component { onClick(ev) } } - + render() { - const {children, style, color, ...props} = this.props - const {state} = this + const { children, style, during, ...props } = this.props + const { state, handleClick } = this - let s = { + const s = { ...style, ...wrapStyle, - ...state.wrapStyle, } return ( -
- {children} - +
+ { children }