react-sprite-animation
Version:
To create animation from the image sprite.
45 lines (29 loc) • 994 B
Markdown
To create animation from the image sprite.
- [Sprite example](https://react-fgjjuw.stackblitz.io)
- [Sprite Code example](https://stackblitz.com/edit/react-fgjjuw?file=src%2FApp.js)
```shell
npm i react-sprite-animation -S
yarn add react-sprite-animation
```
**React** is used with this library but do not come bundled with this library. Please make sure you have those installed before using.
Include library, and call sprite and pass spriteImg source and frames (the number of in sprite)
#### The component
```javascript
import { Sprite } from 'react-sprite-animation';
...
<Sprite
spriteImg={
'https://miro.medium.com/max/1400/1*GJ6ZL0eX8tJE54ZYFSnI9Q.png'
}
frames={8}
/>
```
This are the props of the component.
- spriteImg **{string}** - path to sprite
- frames **{number}** - manually sets current frame
- className **{string}** - to add class to sprite container