1.1.1 • Published 2 years ago
@avioutils/ripple-effects v1.1.1
@avioutils/ripple-effects is third party made for those of you who want to make your elements have a Ripple effect
Features:
- Dynamic color ripple
- Easy to use
Uses Instructions:
- Install the
@avioutils/ripple-effectsfrom terminal by npm or yarn.
npm i @avioutils/ripple-effects
yarn add @avioutils/ripple-effects- Import the
@avioutils/ripple-effectsin to your project.
import Ripple from '@avioutils/ripple-effects'@avioutils/ripple-effectsRipple effect works by using events on elements. You need to initialize the Ripple() object first then use the add() method to get the ripple effect on the component.
import React, { useRef, useEffect } from 'react'
import Ripple from '@avioutils/ripple-effects'
// Method 1
export const MyButton = () => {
const buttonRef = useRef(null)
useEffect(() => {
const ripple = new Ripple()
ripple.new([ buttonRef ])
return () => {
}
}, [])
return (
<button ref={buttonRef}>
ripple 1
</button>
);
}
// Method 2
export const MyButton = () => {
const ripple = new Ripple()
return (
<button onMouseUp={(e) => ripple.add(e)}>
ripple 2
</button>
);
}