Socket
Socket
Sign inDemoInstall

webgl-boom-js

Package Overview
Dependencies
6
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    webgl-boom-js

boomJS is a library for implementing the explosion effect of particle.


Version published
Weekly downloads
8
increased by700%
Maintainers
1
Install size
5.13 MB
Created
Weekly downloads
 

Readme

Source

boomJS

boomJS is a library for implementing the explosion effect of particle.

boomJS can achieve particle explosion effects on any DOM node, and can achieve cool effects through simple APIs.

中文文档

Features

  • Based on webGL implementation, good performance, large-scale particle explosion effect can be achieved
  • Simple, just call boomJS function
  • Lightweight, only 14KB in size
  • Configurable number of particles, initial velocity, acceleration, explosion duration, etc
  • Support animation callbacks
  • Support Promise

Configuration

Parameter nameTypeDefault valueDescription
mnumberwidthThe number of x-axis particles to split, one particle per pixel is split by default
nnumberheightThe number of y-axis particles to split, the default is to split one particle per pixel
anumber0.001Drag acceleration in pixels per frame ^2
speednumber1Initial motion speed in pixels per frame
durationnumber1000Motion time, in frames
onStart() => voidnoneCallback to the beginning of particle effects
onEnd() => voidnoneCallback to end of particle effect
declare function boomJS(node: Element, config?: IConfig): Promise<unknown>;
interface IConfig {
  m?: number; // The number of particles on the x axis of the explosion
  n?: number; // The number of particles on the y axis of the explosion
  a?: number; // Drag acceleration (px / frame ^ 2)
  speed?: number; // Initial motion speed (px / frame)
  duration?: number; // Motion time (frame)
  onStart?: () => void; // Callbacks of beginning
  onEnd?: () => void; // Callback of end
}

Use

import boomJS from "webgl-boom-js";
document.body.addEventListener("click", (e) => {
  const ele = e.target;
  boomJS(ele).then(() => {});
});

Or

import boomJS from "webgl-boom-js";
document.body.addEventListener("click", (e) => {
  const ele = e.target as HTMLElement;
  boomJS(ele, {
    a: 0.001,
    speed: 1,
    duration: 3000,
    onStart: () => {
      ele.style.opacity = "0";
    },
    onEnd: () => {
      ele.style.opacity = "1";
    },
  });
});

Used in the project

Command Line:

npm i webgl-boom-js
import boomJS from "webgl-boom-js";

Use in the page

Introduce:

<script src="./dist/boom.min.js" defer=""></script>

License

MIT

Keywords

FAQs

Last updated on 20 Oct 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc