Particle Effects for Buttons

Publikováno: 25.4.2018

A little library that can be used for bursting particles effects. The idea is to disintegrate an element into particles and make it disappear (or vice versa).

Particle Effects for Buttons was written by Luis Manuel and published on Codrops.

Celý článek

Today we’d like to share a little effect library with you that can be used to create bursting particle effects. The idea is to desintegrate an element into particles and making it disappear (and vice versa). This effect looks really interesting on buttons, so we’ve created a little collection that showcases a bunch of different styles for the effect.

The inspiration for this idea came from Cuberto’s Hyperloop interface shot, Route Selection UI.

The demo is kindly sponsored by Segment: One API, 200+ tools, no more integrations.
If you would like to sponsor one of our demos, find out more here.

The animations are powered by anime.js. Here’s an example of how you can use it:

<!-- Normal HTML element to disintegrate -->
  <button class="button">Button</button>
  
  <script src="anime.min.js"></script>
  <script src="dist/particles.min.js"></script>
  <script>
      // Initialize a new instance of Particles to disintegrate/integrate the button
      var particles = new Particles('.button');
  
      // Disintegrate the button into particles
      particles.disintegrate();
  
      // particles.integrate(); // would do the opposite
  </script>

The following options are available:

NameTypeDefaultDescription
canvasPaddingInteger150Padding for the generated canvas that will be positioned right behind the target element. A canvasPadding = 0 will cause the canvas and the target element to have the same dimensions.
durationInteger1000Duration (ms) to perform the animations of target element and particles.
easingString or FunctioneaseInOutCubicEasing function to perform the animation of target element. It will be passed directly to anime.js.
typeStringcircleType of particle. Could be any of the following values: circle, rectangle, triangle
styleStringfillStyle of particle. Could be any of the following values: fill, stroke.
directionStringleftDirection to start disintegrating the element. Could be any of the following values: left, righttop, bottom. The opposite direction will be used to perform the integrate operation.
sizeFloat or FunctionRandom from 1 to 4Size (px) for particles.
speedFloat or FunctionRandom from -2 to 2Pixels per frame that a particle will be moved. It could be a function to set it randomly per particle (as default value).
colorStringTarget’s background-colorColor used to fill the particles.
particlesAmount
Coefficient
Float3A coefficient to calculate the amount of particles to animate. A particlesAmountCoefficient = 0 will result in 0 particles, while bigger values will increase the amount of particles.
oscillation
Coefficient
Float20A coefficient to calculate the oscilation of particles while animating. A oscilationCoefficient = 0 will result in no oscilation (straight movements), while bigger values will increase the oscilation, resulting in
a kind of randomness.
beginFunctionundefinedExecute a function at the beginning of the animation.
completeFunctionundefinedExecute a function at the end of the animation.

We hope you enjoy this and find it useful!

References and Credits

Particle Effects for Buttons was written by Luis Manuel and published on Codrops.

Nahoru
Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tímto souhlasíte. Další informace