1.1.3 • Published 1 year ago

@chaocore/ripple v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@chaocore/ripple

The very easy, performance and flexible to use JavaScript/TypeScript library for creating a ripple effect.

Demonstration

Demonstration library

Installing

Using npm:

npm i @chaocore/ripple

Using yarn:

yarn add @chaocore/ripple

Using pnpm:

pnpm add @chaocore/ripple

Using CDN:

<script src="https://unpkg.com/@chaocore/ripple"></script>

or

<script defer src="https://unpkg.com/@chaocore/ripple"></script>

Usage


React

import { useRipple } from "@chaocore/ripple";

function MyComponent() {
    const ripple = useRipple(options);

    return <button ref={ripple} className="btn">Click Here</button>
}

Native js

const btn = document.querySelector(".btn");

btn.addEventListener("pointerdown", (event) => {
    createRippleEffect(event, btn, options) // or window.createRippleEffect
})

Options

NameDefaultType
color"currentColor"string
easing"ease-out"string
duration400msnumber
dissolveDuration300msnumber
delay75msnumber
initialOpacity0.2number
finalOpacity0.1number
considerDisabledAttrtrueboolean
turnOfffalseboolean

Description of options

NameDescription
colorDefines the color of the ripple.
easingAny valid CSS transition-timing-function.
durationThe duration of the ripple in milliseconds.
dissolveDurationThe dissolve duration of the ripple in milliseconds.Starts after the end of the main duration.
delayThe animation delay in milliseconds during which the animation maybe canceled if the current pointer action is interrupted for some reason and pointer events are no longer generated.Read about the pointercancel event
initialOpacityThe opacity of the ripple at the beginning of the animation.
finalOpacityThe opacity of the ripple at the end of the animation.
considerDisabledAttrDon't display a ripple effect if the element has the disabled attribute.
turnOffDon't display a ripple effect.

License

Copyright © 2024, Alexey Kipichenko. Released under the MIT License.