Code Monkey home page Code Monkey logo

react-sprite-animator's Introduction

React Sprite Animator

Dependabot

This is a component that animates through an image sprite.

Install

npm i react-sprite-animator -S
# or
yarn add react-sprite-animator

React is used with this library but do not come bundled with this library. Please make sure you have those installed before using.

Usage

You are able to use this library as a component or as a hook.

The component

import { SpriteAnimator } from 'react-sprite-animator'
...
<SpriteAnimator
  sprite="/path-to/sprite.svg"
  width={100}
  height={100}
/>

The hook

import { useSprite } from 'react-sprite-animator'

const MyComponent = () => {
  const styles = useSprite({
    sprite: '/path-to/sprite.svg',
    width: 100,
    height: 100,
  })

  return <div style={style} />
}

Props

This is the same for the hooks options and the props of the component.

  • width {number} - width of clipped sprite (original, non-scaled dimensions)
  • height {number} - height of clipped sprite (original, non-scaled dimensions)
  • scale {number} - scale of the original sprite (default: 1, retina / @2x: 2)
  • sprite {string} - path to sprite
  • direction {string} - horizontal/vertical
  • shouldAnimate {bool} - if the sprite should animate
  • startFrame {number} - the frame to start animation
  • fps {number} - the frame rate (frames per second) target
  • stopLastFrame {bool} - stops animation from looping
  • frame {number} - manually sets current frame
  • onEnd {function} - callback when the animation finishes (only triggered when stopLastFrame is true)

Only required for two-dimensional sprites

  • frameCount {number} - the total frame count of the sprite
  • wrapAfter {number} - the row or column count of the sprite (direction: "horizontal" -> columns, "vertical" -> rows)

react-sprite-animator's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar direct-fuel-injection avatar dlindenkreuz avatar etnlbck avatar greenkeeper[bot] avatar htopia avatar jcblw avatar krisaoe avatar ogaseb avatar timarney avatar webpty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-sprite-animator's Issues

An in-range update of prop-types is breaking the build 🚨

The devDependency prop-types was updated from 15.6.2 to 15.7.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

prop-types is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Change Request: frameCount

Hi.
Thanks a lot for the awesome lib.
I was using it in my react app with the SpriteAnimator component.
I finding a naming convention bit weird. The 'framecount' is actually not the total frames that will be played from the 'startFrame'. It's actually the ending frame.
That is ,
startFrame=2 ,framecount=5 => will make the lib play frames 2,3 and 4.
It's a bit confusing.
So, it's a humble suggestion to rename framecount to endframe.

Keeping a consistent height

right now there is a bit of jumping between the state of being loaded and not loaded sprite. We should probably have that blank space so the ui does not jump, or at least have a way to configure the module to retain the height.

Dynamic resizing of sprites

I'm trying to select 32px by 32px sprites from a larger spritesheet, but the sprites display as 32px by 32px. I'd like to take that 32px by 32px sprite from my spritesheet file and dynamically resize it with CSS styles such as "width: '100%').

Using the following inline styling in React has no effect:

<SpriteAnimator
   style={{
      imageRendering: 'pixelated',
      position: 'absolute',
      width: '100px',
   }}
   sprite={body}
   width={32}
   height={32}
   shouldAnimate={false}
   frame={0}
/>

Are there solutions to this problem?

Thanks!

Sprite image load 3 times

I see in my browser's network tab that the sprite image src loads 3 times...

In some browsers it's no issue as the first download of the image gets cached and so 2nd and 3rd loadings are basically instantaneous.

However, in another browser I have, the image does not get cached. So it actually downloads the sprite image 3 times (and in my case it is a big file) which makes it slow.

Request: calling to stop animation

Hi, first of all, great package. But I have little problem, when I am redirecting my page to another subpage, there is memory leak. I need in useEffect cleanup function stop animation, but there is no option to stop it, something like, sprite.stop(),.. and this indicate memory leaks in that case.

doesn't work on some mobile browser

i tried testing with the default browser of an oppo phone. the component doest show up... works fine on google mobile, firefox mobile and safari mobile though. let me try on other android devices.
I think this is not a major issue.

Display sprites with imageRendering: 'pixelated' property

I'm not sure if there's already a way to do this, but upscaling a sprite by setting scale to a fraction makes it fuzzy. I'm wondering if there's a way to specify the imageRendering property for the displayed image, as setting it to 'pixelated' usually removes the blurriness.

Thanks!

"startFrame" value not effecting animation

i'm trying to use startFrame value but animations still starting at 0. is there something i'm doing wrong?

<SpriteAnimator startFrame={1} frameCount={10} sprite={sheetFile} width={150} height={150}/>

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 6.1.0 to 6.2.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v6.2.0
  • fee6acb Update: support bigint and dynamic import (refs #11803) (#11983) (Toru Nagashima)
  • afd8012 New: noInlineConfig setting (refs eslint/rfcs#22) (#12091) (Toru Nagashima)
  • 3d12378 Update: Fix accessor-pairs to enforce pairs per property in literals (#12062) (Milos Djermanovic)
  • 8cd00b3 New: function-call-argument-newline (#12024) (finico)
  • 30ebf92 Fix: prefer-template autofix produces syntax error with octal escapes (#12085) (Milos Djermanovic)
  • 13c3988 Fix: Check literal type explicitly in dot-notation (#12095) (Milos Djermanovic)
  • 3e5ceca Fix: Handle empty string property names in getFunctionNameWithKind (#12104) (Milos Djermanovic)
  • 9a043ff Fix: no-duplicate-case false positives on Object.prototype keys (#12107) (Milos Djermanovic)
  • fe631af Chore: minor typo fix (#12112) (James George)
  • 4cb7877 Fix: fix no-extra-parens ignores some nodes (#11909) (Pig Fang)
  • 2dc23b8 Update: fix no-dupe-keys false negatives on empty string names (#12069) (Milos Djermanovic)
  • 19ab666 Fix: yoda exceptRange false positives on empty string property names (#12071) (Milos Djermanovic)
  • d642150 Update: Check empty string property names in sort-keys (#12073) (Milos Djermanovic)
  • acce6de Fix: class-methods-use-this reports 'undefined' names (#12103) (Milos Djermanovic)
  • 92ec2cb Fix: Allow bind call with a single spread element in no-extra-bind (#12088) (Milos Djermanovic)
  • bfdb0c9 Fix: no-extra-boolean-cast invalid autofix for Boolean() without args (#12076) (Milos Djermanovic)
  • 34ccc0c Chore: Remove TDZ scope type condition from no-unused-vars (#12055) (Milos Djermanovic)
  • 01d38ce Docs: Remove TDZ scope from the scope manager interface documentation (#12054) (Milos Djermanovic)
  • 1aff8fc Update: warn about mixing ternary and logical operators (fixes #11704) (#12001) (Karthik Priyadarshan)
  • 11be2f8 Docs: do not recommend global-installed usage (#12016) (薛定谔的猫)
  • cf31dab Fix: no-restricted-syntax - correct the schema (#12051) (Brad Zacher)
  • fbec99e Update: fix class-methods-use-this false negatives with exceptMethods (#12077) (Milos Djermanovic)
  • fb08b7c Docs: Remove readonly/writable global logic from no-undef (fixes #11963) (#12053) (Milos Djermanovic)
  • 5b5934b Sponsors: Sync README with website (ESLint Jenkins)
  • 9156760 Sponsors: Sync README with website (ESLint Jenkins)
  • f5e0cc4 Update: Check computed method keys in no-extra-parens (#11973) (Milos Djermanovic)
  • d961438 Docs: Fix Incorrect Documentation (#12045) (Michael Miceli)
  • 887d08c Sponsors: Sync README with website (ESLint Jenkins)
  • d90183f Docs: add a case to func-names (#12038) (Chiawen Chen)
  • 8a5b62d Docs: no use eslint.linter in code example (#12037) (薛定谔的猫)
  • 5831767 Update: report location of func-names (fixes #12022) (#12028) (Pig Fang)
Commits

The new version differs by 33 commits.

  • 320b7bd 6.2.0
  • 9601f5a Build: changelog update for 6.2.0
  • fee6acb Update: support bigint and dynamic import (refs #11803) (#11983)
  • afd8012 New: noInlineConfig setting (refs eslint/rfcs#22) (#12091)
  • 3d12378 Update: Fix accessor-pairs to enforce pairs per property in literals (#12062)
  • 8cd00b3 New: function-call-argument-newline (#12024)
  • 30ebf92 Fix: prefer-template autofix produces syntax error with octal escapes (#12085)
  • 13c3988 Fix: Check literal type explicitly in dot-notation (#12095)
  • 3e5ceca Fix: Handle empty string property names in getFunctionNameWithKind (#12104)
  • 9a043ff Fix: no-duplicate-case false positives on Object.prototype keys (#12107)
  • fe631af Chore: minor typo fix (#12112)
  • 4cb7877 Fix: fix no-extra-parens ignores some nodes (#11909)
  • 2dc23b8 Update: fix no-dupe-keys false negatives on empty string names (#12069)
  • 19ab666 Fix: yoda exceptRange false positives on empty string property names (#12071)
  • d642150 Update: Check empty string property names in sort-keys (#12073)

There are 33 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Typescript Support

There is no typescript support to this project.

When you try to use it on a typescript project, the IDE shows this error.
Could not find a declaration file for module 'react-sprite-animator'. 'c:/workspace/alyson/frontend-fdte/node_modules/react-sprite-animator/lib/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/react-sprite-animatorif it exists or add a new declaration (.d.ts) file containingdeclare module 'react-sprite-animator';ts(7016)

Feature Request: Complete Event -> Bug: onEnd fires at start

Hi there,
First of all thank you so much for this simple and lightweight library, it's been super helpful!
I was wondering if we could get a complete event when an animation is finished.
It could also come in handy being able to trigger an event on a specific frame, so we can play sound effects and stuff like that.
Let me know if this is already supported.
Thanks again!

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

New Release for react 16?

I see there's been recent commits updating the peer dependency for react 16. Is there any plans to do a publish to get rid of the pesky npm WARN [email protected] requires a peer of [email protected] || 0.14.x || ^15.x but none is installed. You must install peer dependencies yourself. warnings?

An in-range update of eslint-plugin-react is breaking the build 🚨

The devDependency eslint-plugin-react was updated from 7.12.4 to 7.13.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 74 commits.

  • f39829f Update CHANGELOG and bump version
  • 9e81dde [Deps] update jsx-ast-utils, resolve
  • e73a692 Merge pull request #2256 from mateuszsokola/master
  • b5fc9bf [fix] jsx-props-no-multi-spaces: support generic components (ts)
  • 8bd3837 Fix Node 4 compatibility
  • 005dad3 Revert "Replace mocha by jest"
  • 6e4f43e Replace mocha by jest
  • 09f580c Replace typescript-eslint-parser by @typescript-eslint/parser
  • 861fdef [fix] prop-types: fix case with destructuring and defualt param
  • 9fbd037 Fix ESLint 6 compat by providing parser as absolute path to RuleTester
  • 8041075 Fix jsx-curly-brace-presence schema defaults
  • 9cec705 Add next ESLint version to Travis
  • 0d4725e Add Node 12 and remove Node 4/6 from Travis
  • 9192ec3 Update devDependencies
  • d5d2e82 Merge pull request #2250 from guliashvili/master

There are 74 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of tape is breaking the build 🚨

The devDependency tape was updated from 4.10.1 to 4.10.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

tape is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 7 commits.

  • 2c6818a v4.10.2
  • 15b2dfc [fix] don't consider 'ok' of todo tests in exit code
  • 9ec3a0f [Dev Deps] update eslint, js-yaml
  • 3f337d1 [meta] set save-prefix to ~ (meant for runtime deps)
  • c30e492 [Deps] update glob, resolve
  • 25b4a24 Minor punctuation/highlighting improvement
  • c481dae [Refactor] Removed never-read inErrorState from index.js

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-react is breaking the build 🚨

Version 7.4.0 of eslint-plugin-react just got published.

Branch Build failing 🚨
Dependency eslint-plugin-react
Current Version 7.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint-plugin-react is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v7.4.0

Added

  • Add Flow 0.53 support (#1376 @jseminck)
  • Add jsx-curly-brace-presence rule (#1310 @jackyho112)
  • Add support for Flow IntersectionTypeAnnotation to prop-types and no-unused-prop-types (#1364 #1323 @jseminck)
  • Add support for Flow TypedArgument to no-unused-prop-types (#1412 @jseminck)
  • Add support for Flow ClassExpressions to prop-types (#1400 @jseminck)
  • Add support for Flow read-only props to no-unused-prop-types (#1388 @jseminck)
  • Add more tests for prop-types and no-unused-prop-types (#1381 @DianaSuvorova)
  • Add support for increment and decrement operations to no-direct-mutation-state (#1386 @zpao)

Fixed

Changed

Commits

The new version differs by 112 commits.

  • dc9f85e Update CHANGELOG and bump version
  • 99b12a2 Merge pull request #1432 from jneuendorf/master
  • d2005b1 fixed typos in no-multi-comp
  • ddd05b1 Update CHANGELOG and bump version
  • 7e336aa Merge pull request #1415 from jseminck/intersection-imported-type
  • ad26580 Merge pull request #1387 from zpao/update-expression
  • 09c4ed7 Add tests for {...} & Props in addition to Props & {...}
  • 357dcda buildReactDeclarationTypes to always return an object
  • 0ee5e93 Rewrite reduce to ignorePropsValidation as some()
  • 3e9aefe Make buildTypeAnnotationDeclarationTypes always return an object instead of boolean or an object
  • 3e4d184 Aadd support also for no-unused-prop-types
  • 19a2911 Clean up the code a bit
  • 20f75ee Add support for TypeA & { ... }
  • a771125 Add similar supprt for no-used-prop-types
  • 87aca04 Add support for multiple Flow IntersectionTypeAnnotations and skip propTypes when one of the intersected props is not found, e.g. when imported

There are 112 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of browserify is breaking the build 🚨

The devDependency browserify was updated from 16.3.0 to 16.4.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

browserify is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 5 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of tape-run is breaking the build 🚨

Version 3.0.3 of tape-run was just published.

Branch Build failing 🚨
Dependency tape-run
Current Version 3.0.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

tape-run is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.