Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bursting particle effect buttons for React 🎉

License

NotificationsYou must be signed in to change notification settings

transitive-bullshit/react-particle-effect-button

Repository files navigation

Bursting particle effect buttons for React.

NPMBuild StatusJavaScript Style Guide

Demo

This library is a React port of an awesomeCodrops Article byLuis Manuel (originalsource).

Install

npm install --save react-particle-effect-button

Usage

Check out theDemo to see it in action.

importReact,{Component}from'react'importParticleEffectButtonfrom'react-particle-effect-button'classAppextendsComponent{state={hidden:false}render(){return(<ParticleEffectButtoncolor='#121019'hidden={this.state.hidden}>        BUTTON CONTENT GOES HERE</ParticleEffectButton>)}}

Note thatchildren can be anything from a simple<button> to a complex React subtree. Thechildren should represent the button's contents.

You change thehidden boolean prop to kick-off an animation, typically as a result of a click on the button's contents. Ifhidden changes totrue, the button will perform a disintegrating animation. Ifhidden changes tofalse, it will reverse and reintegrate the original content.

Props

PropertyTypeDefaultDescription
hiddenbooleanfalseWhether button should be hidden or visible. Changing this prop starts an animation.
colorstring'#000'Particle color. Should match the button content's background color
childrenReact NodeundefinedThe contents of the button.
durationnumber1000Animation duration in milliseconds.
easingstring'easeInOutCubic'Animation easing.
typestringcircle'circle' or 'rectangle' or 'triangle'
stylestringfill'fill' or 'stroke'
directionstring'left''left' or 'right' or 'top' or 'bottom'
canvasPaddingnumber150Amount of extra padding to add to the canvas since the animation will overflow the content's bounds
sizenumberfuncrandom(4)
speednumberfuncrandom(4)
particlesAmountCoefficientnumber3Increases or decreases the relative number of particles
oscillationCoefficientnumber20Increases or decreases the relative curvature of particles
onBeginfuncnoopCallback to be notified once an animation starts.
onCompletefuncnoopCallback to be notified once an animation completes.

I tried to keep the properties exactly the same as in the original codrops version.

Related

This module was bootstrapped withcreate-react-library.

License

MIT ©Travis Fischer

Support my OSS work byfollowing me on twittertwitter

About

Bursting particle effect buttons for React 🎉

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp