Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

canvas-animations

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-animations

Creating frame animation out of the native power of canvas, no dependency attached

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

canvas-animations

Canvas-Animations does one single thing; it turns a spritesheet into an animation. Meanwhile, it offers controls like fps, animationIteraionCount, play, stop, destroy to suit your particular needs, together with an optional onAnimationEnd handler.

🍾 Features

  1. Light as a feather, zero dependency.
  2. JS framework free, can be used with any JS framework.
  3. Support 3 forms of spritesheet: spritesheet with multiple rows, spritesheet with single row, spritesheet with single column.
  4. Configurable animation speed, animation iteration count, autoplay mode.
  5. The canvas element generated would be automatically scale to match the dimension of container element you have set.

🔦 How to use?

Step 1: Installation

Using npm:

  npm install canvas-animations

Using yarn:

  yarn add canvas-animations
Step 2: Import helper setCanvasAnimation and pass down your config
import setCanvasAnimation from 'canvas-animations';

const config = {
  // config whatever you need
};
const anims = setCanvasAnimation(config);

⁉️ What can go in the config above 🧩?

Property NameTyperequireddefaultdescription
containerObjectYes-the html element that the generated canvas animation would be appended to
autoPlayBooleanNotruewhether to autoplay animation or not
spriteSheetStringYes-the image url of your spritesheet
totalFrameCountsNumberYes-the total frames of your spritesheet
animationIterationCountNumber, stringNo1iteration count for your spritesheet, 'infinite' for infinite loop
widthNumberYes-the width of each frame in your spritesheet
heightNumberYes-the height of each frame in your spritesheet
fpsNumberNo30the fps for your animation, valid range between 0 and 60
onAnimationEndFunctionNonullonAnimationEnd handler for your animation
Step 3: Control your animation
anims.play(); // start to play your anims
anims.stop(); // stop your anims from playing
anims.destroy(); // destroy your animsonAnimationEnd

🍻 You're all set! Have fun animating 🍻

Keywords

FAQs

Package last updated on 05 Jan 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc