Skip to content

Commit

Permalink
Clean the core
Browse files Browse the repository at this point in the history
  • Loading branch information
rwu823 committed Jan 28, 2017
1 parent 449640f commit bea3f5e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {PropTypes} from 'react'
import React, { PropTypes } from 'react'

const rippleStyle = {
position: 'absolute',
Expand Down Expand Up @@ -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
Expand All @@ -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`,
}
Expand All @@ -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 (
<div {...props} style={s} onClick={this.handleClick}>
{children}

<div {...props} style={s} onClick={handleClick}>
{ children }
<s style={{
...rippleStyle,
...state.rippleStyle,
Expand Down

0 comments on commit bea3f5e

Please sign in to comment.