react-apng
APNG implementation on canvas as a React.js component, provides functions for control it (base on apng-js).
Demo & Examples
Live demo: https://sl2782087.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 react-apng --save
yarn add react-apng --save
Usage
Require the react-apng component and render it with JSX:
;;//const ApngComponent = require('react-apng'); or this way; Component { return <ApngComponent src=apic1 />; } React;
Methods && State
methods
play
play the apngpause
pause the apngstop
stop the apngone
play the apng once
state
isPlay
apng play status
Component { const apngcom = thisrefsapngcom; const isPlay = apngcomisPlay; ifisPlay apngcom; else apngcom; } { return <ApngComponent ref="apngcom" onClick=thisplayAndPause 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 classNamestyle
string
canvas stylesrc
string
local image pathautoPlay
bool
auto play apng (default false)rate
floot
apng play rate (default 1.0)onClick,onMouseOver...
function
bind events like a real dom
Copyright (c) 2018 wangzy MIT Licensed.