
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
react-spriter
Advanced tools
ReactSpriter is a React component that allows you to create animated sprites by providing a convenient interface
React Spriter is a React component that allows you to create animated sprites using styled-components. It simplifies the process of animating sprites by providing a convenient interface to define sprite properties and animations.
DEMOS: https://react-spriter.callumeddisford.co.uk/
Build a game! Tell a story! Animate your icons!
To use ReactSpriter in your React project, you can install it via npm or yarn:
npm install react-spriter
or
yarn add react-spriter
import ReactSpriter from "react-spriter";
class MyComponent extends React.Component {
render() {
return (
<ReactSpriter
sprite={sprite}
spriteWidth={spriteWidth}
frameWidth={frameWidth}
frameHeight={frameHeight}
elementWidth={elementWidth}
duration={animationDuration}
isInfinite={isInfinite}
shouldAnimate={shouldAnimate}
layer={layer}
/>
);
}
}
Field | Type | Description |
---|---|---|
sprite | string | The URL of the sprite image. |
frameWidth | number | The width of each frame in the sprite. |
frameHeight | number | The height of each frame in the sprite. |
elementWidth | number | (optional) Use this option to resize the sprite to a given pixel width, the element height is calculated automatically to mantain apsect ratio. |
spriteWidth | number | The total width of the sprite image. |
animationDuration | number | The duration of the animation in milliseconds. |
isInfinite | boolean | Whether the animation should loop infinitely. |
shouldAnimate | boolean | (optional) Whether the animation should start automatically. Defaults to true. |
layer | number | (optional) The layer of the sprite animation. If multiple sprites are layered on top of each other, this value determines the order of rendering. |
Here's an example of how you can use ReactSpriter to animate a sprite, in this example each frame width is 64
and the total sprite image width is 512
this indicates there are 8
frames to animate over:
import React from "react";
import ReactSpriter from "react-spriter";
import sprite from "path/to/sprite.png";
const MyComponent = () => {
const spriteWidth = 512;
const frameWidth = 64;
const frameHeight = 64;
const elementWidth= 50;
const animationDuration = 1000;
const isInfinite = true;
const shouldAnimate = true;
const layer = 0;
return (
<ReactSpriter
sprite={sprite}
spriteWidth={spriteWidth}
frameWidth={frameWidth}
frameHeight={frameHeight}
elementWidth={elementWidth}
duration={animationDuration}
isInfinite={isInfinite}
shouldAnimate={shouldAnimate}
layer={layer}
/>
);
};
export default MyComponent;
Please check out the src/examples
directory for more
To start storybook locally:
npm install
npm run storybook
FAQs
ReactSpriter is a React component that allows you to create animated sprites by providing a convenient interface
We found that react-spriter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.