Skip to content

LexRiver/inferno-ripple-effect

Repository files navigation

Inferno Ripple Effect

Inferno Component to make Google material design ripple effect. It's adopted from react-ripple

DEMO

How to run example

Just clone or download this repository and run example

git clone https://github.com/LexRiver/inferno-ripple-effect.git
cd inferno-ripple-effect
npm install
npm start

then open localhost:8080 in your browser


Installation

No npm installation yet, just copy RippleButton.tsx, RippleEffect.css, RippleEffect.tsx to your project and modify them as you need. If you are using jsx, just rename the tsx files and remove interfaces.


Usage

Using predefined RippleButton

<RippleButton onClick={myEvent}>My ripple button</RippleButton>

See detailed example


Add ripple effect to any div or your component

Please see RippleButton example to create your own component with ripple effect.

The most important steps:

  • add RippleEffect child component to your component
    <div...>
        <RippleEffect cursorPos={this.state.cursorPos} duration={500} color={'rgba(0,0,0,0.2)'} />
    </div>
  • set style of your component to position: relative; overflow: hidden, position can't be static
  • on click event update cursorPos like this
	handleClick = (e) => {
		// Get Cursor Position
		let cursorPos = {
			top: e.clientY,
			left: e.clientX,
			time: Date.now()
		}
		this.setState({ cursorPos: cursorPos })
    }


Credits

License

MIT

About

Ripple effect for InfernoJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published