From f5e78a09aed65f0f571a2e2bb428b40db80fdbe7 Mon Sep 17 00:00:00 2001 From: Christian Hubbard Date: Tue, 1 Oct 2024 16:43:22 -0700 Subject: [PATCH 1/2] Update index.js --- src/index.js | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/index.js b/src/index.js index aa67039..2cc4cbb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,9 @@ -import React from 'react' -import PropTypes from 'prop-types' -import { useSprite } from './useSprite' -export { useSprite, loadImage } from './useSprite' +import React from 'react'; +import PropTypes from 'prop-types'; +import { useSprite } from './useSprite'; +export { useSprite, loadImage } from './useSprite'; -const noop = () => {} +const noop = () => {}; const propTypes = { className: PropTypes.string, @@ -24,25 +24,25 @@ const propTypes = { wrapAfter: PropTypes.number, frame: PropTypes.number, reset: PropTypes.bool, -} +}; export const SpriteAnimator = ({ - startFrame, + startFrame = 0, sprite, width, height, - direction, - onError, - onLoad, - onEnd, + direction = 'horizontal', + onError = noop, + onLoad = noop, + onEnd = noop, frameCount, - fps, - shouldAnimate, + fps = 60, + shouldAnimate = true, stopLastFrame, reset, frame, className, - scale, + scale = 1, wrapAfter, }) => { const style = useSprite({ @@ -62,20 +62,9 @@ export const SpriteAnimator = ({ frame, scale, wrapAfter, - }) + }); - return
-} + return
; +}; -SpriteAnimator.propTypes = propTypes -SpriteAnimator.defaultProps = { - scale: 1, - direction: 'horizontal', - shouldAnimate: true, - loop: true, - startFrame: 0, - fps: 60, - onError: noop, - onLoad: noop, - onEnd: noop, -} +SpriteAnimator.propTypes = propTypes; From 7fa93c2ef2f5575c0b1a0f9ff0fac1ed506d560b Mon Sep 17 00:00:00 2001 From: Christian Hubbard Date: Tue, 1 Oct 2024 16:44:06 -0700 Subject: [PATCH 2/2] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d505b05..be20d04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-sprite-animator", - "version": "2.0.2", + "version": "2.0.3", "description": "A react component that loads sprite image and the runs it as an animation", "main": "lib/index.js", "scripts": {