You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

jw-animate-canvas

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jw-animate-canvas

A react component for canvas integrated with animation feature.

0.1.6
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

jw-animate-canvas

A react component for canvas integrated with animation feature. It is a combination of canvas and animator.

NPM version build status node version npm download

Demo

Install

NPM

Props

PropDescription
maintainPixelSize(optional)whether the canvas should keep dimension from the moment it was created. Default: true
onResize(optional)event handler when the canvas is being resized.
contextType(optional)canvas context type. Default: "2d"
animator(optional)the animator object for controlling the animation. If not provided, it will be created from within.
animate(optional)animation method. Parameters:
- context: canvas context
- width: context width
- height: context height
- timeDiff: time difference between the last animate time (in seconds).

Usage

import React, { Component } from "react";
import ReactDOM from "react-dom";
import AnimateCanvas from "jw-animate-canvas";

class Example extends Component {
  constructor(props) {
    super(props);

    this.resizeHandler = this.resizeHandler.bind(this);
    this.animate = this.animate.bind(this);
  }

  componentDidMount() {
    const canvas = this.myCanvas;
    const { animator } = canvas;
    /** Start the animation. */
    animator.start();

    /** Pause the animation. */
    animator.pause();

    /** Resume the animation. */
    animator.resume();
  }

  resizeHandler(width, height) {
    /** ... **/
  }

  animate(context, width, height, timeDiff) {
    /** ... **/
  }

  render() {
    return (
      <AnimateCanvas
        ref={myCanvas => (this.myCanvas = myCanvas)}
        onResize={this.resizeHandler}
        animate={this.animate}
      />
    );
  }
}

ReactDOM.render(<Example />, document.getElementById("root"));

Keywords

canvas

FAQs

Package last updated on 18 Feb 2019

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