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

@wwzzyying/react-apng

v1.0.3

Published

A React component make apng to canvas for controling apng with apng-js's events callback

Downloads

187

Readme

react-apng

APNG implementation on canvas as a React.js component, provides functions for control it (base on apng-js).

Notice

Based on react-apng

  • added support for callback events in apng-js, such as play, frame, end, and other events.
  • added Typescript declaration of ApngComponent
  • fix apng-js occasional frame skipping after calling pause

Demo & Examples

Live demo: https://wwzzyying.github.io/react-apng/

To run the examples locally:

npm install or yarn
npm start or yarn start

Then open localhost:8080/docs/ in a browser.

Installation

react-apng is available through npm or yarn:

npm install @wwzzyying/react-apng --save
yarn add @wwzzyying/react-apng --save

Usage

Require the react-apng component and render it with JSX:

import React from 'react';
import ApngComponent from '@wwzzyying/react-apng';
//const ApngComponent = require('react-apng'); or this way
import apic1 from './apic1.png';

class ApngComponent extends React.Component {
	render() {
		return <ApngComponent src={apic1} />;
	}
}

React.render(<App />, document.getElementById('app'));

Methods && State

methods

  • play play the apng
  • pause pause the apng
  • stop stop the apng
  • one play the apng once

state

  • isPlay apng play status
class ApngComponent extends React.Component {
	playAndPause =()=>{
		const apngcom = this.refs.apngcom;
		const isPlay = apngcom.isPlay;
		if(isPlay){
			apngcom.pause();
		}else {
			apngcom.play();
		}
	}
	render() {
		return (
				<ApngComponent
					ref="apngcom"
					onClick={this.playAndPause}
					src={apic1}
				/>;
			)
	}
}

You can interact with the component instance using a ref after the componentDidMount lifecycle event has fired (including inside the componentDidMount event in a parent Component).

Properties

  • className string canvas className
  • style string canvas style
  • src string local image path
  • autoPlay bool auto play apng (default false)
  • rate floot apng play rate (default 1.0)
  • onPlay playback started
  • onFrame frame played (frame number passed as event parameter)
  • onPause playback paused
  • onStop playback stopped
  • onEnd playback ended (for APNG with finite count of plays)
  • onClick,onMouseOver... function bind events like a real dom

Copyright (c) 2018 wangzy MIT Licensed.