npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

canvas-animations

v0.3.1

Published

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

Downloads

4

Readme

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 Name | Type | required | default | description | | --------------------------- | -------- | -------- | ------- | ------------------------------------------------------------------------- | | container | Object | Yes | - | the html element that the generated canvas animation would be appended to | | autoPlay | Boolean | No | true | whether to autoplay animation or not | | spriteSheet | String | Yes | - | the image url of your spritesheet | | totalFrameCounts | Number | Yes | - | the total frames of your spritesheet | | animationIterationCount | Number, string | No | 1 | iteration count for your spritesheet, 'infinite' for infinite loop | | width | Number | Yes | - | the width of each frame in your spritesheet | | height | Number | Yes | - | the height of each frame in your spritesheet | | fps | Number | No | 30 | the fps for your animation, valid range between 0 and 60 | | onAnimationEnd | Function | No | null | onAnimationEnd 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 🍻