mileung / rn-sprite-sheet

A sprite sheet animation library for React Native
https://www.npmjs.com/package/rn-sprite-sheet
153 stars 35 forks source link

uri does work as a source by providing its dimensions as well #11

Closed gorvinsky closed 5 years ago

gorvinsky commented 5 years ago

In the documentations, it is stated that { uri } will not work as a source. However, it's not entirely true. It will work if you provide its dimentions as well. Refer below for more info.

This will not work:

source = { uri: 'someurl' };

This will work:

source = { uri: 'someurl', width: 100, height: 100 };

Do correct me if I'm wrong.

mileung commented 5 years ago

You are correct if resolveAsset can parse the height and width properties. https://github.com/MiLeung/rn-sprite-sheet/blob/master/src/SpriteSheet.js#L44

So you have a working example using source = { uri: 'someurl', width: 100, height: 100 };?

gorvinsky commented 5 years ago

@MiLeung I've been using it yes.

mileung commented 5 years ago

Nice, can you please update the README and create a PR for this?

gorvinsky commented 5 years ago

Nice, can you please update the README and create a PR for this?

Done.

mileung commented 5 years ago

Thank you!

gorvinsky commented 5 years ago

Thank you!

@MiLeung Sorry, I just recall that the proptypes of source is currently set to PropTypes.number.isRequired. You may want to change it to PropTypes.any.isRequired for it to work properly.