Socket
Socket
Sign inDemoInstall

@jworkshop/canvasanimator

Package Overview
Dependencies
3
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jworkshop/canvasanimator

A canvas react UI component integrated with animation feature.


Version published
Maintainers
1
Created

Readme

Source

canvasanimator

A canvas react UI component integrated with animation feature. It is an extension of canvas, integrated with an animator.

NPM version build status node version npm download

install

NPM

Usage

import React, { Component } from "react";
import ReactDOM from "react-dom";

import CanvasAnimator from "@jworkshop/canvasanimator";

import "./style.css";

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

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

  someFunction() {
    const canvas = this.myCanvas;

    /** Retrieve the canvas react component. */
    canvas.getCanvasElement();

    /** Get the width of the canvas react component. */
    canvas.getCanvasWidth();

    /** Get the width of the canvas react component. */
    canvas.getCanvasHeight();

    /** Get the context of the canvas. */
    canvas.getContext();

    /** Get the image data of the canvas with a give area. */
    canvas.getImageData(startX, startY, endX, endY);

    /** Start the animation. */
    canvas.start();

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

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

  resizeHandler(width, height) {
    // Do you stuff
  }

  animate(context, width, height, timeDiff) {
    // Do you stuff
  }

  pauseHandler() {
    // Do you stuff
  }

  resumeHandler() {
    // Do you stuff
  }

  render() {

    return (
      <CanvasAnimator
        ref={myCanvas => this.myCanvas = myCanvas}
        className="className"
        style={ ... }
        canvasClassName="canvasClassName"
        canvasStyle={ ... }
        onResize={this.resizeHandler}
        animate={this.animate}
        onPause={this.pauseHandler}
        onResume={this.resumeHandler}
      />
    );
  }
}

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

Keywords

FAQs

Last updated on 25 Apr 2018

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