Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Fixed react-native under expo-web image size issue #81

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/native/components/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export default class Sprite extends Component {
ticksPerFrame: PropTypes.number,
tileHeight: PropTypes.number,
tileWidth: PropTypes.number,
sourceHeight: PropTypes.number,
sourceWidth: PropTypes.number
};

static defaultProps = {
Expand All @@ -29,6 +31,8 @@ export default class Sprite extends Component {
ticksPerFrame: 4,
tileHeight: 64,
tileWidth: 64,
sourceHeight: 64,
sourceWidth: 64
};

static contextTypes = {
Expand All @@ -54,6 +58,10 @@ export default class Sprite extends Component {
this.loopID = this.context.loop.subscribe(animate);
}

UNSAFE_componentWillReceiveProps(nextProps) {
return this.componentWillReceiveProps(nextProps)
}

componentWillReceiveProps(nextProps) {
if (nextProps.state !== this.props.state) {
this.finished = false;
Expand Down Expand Up @@ -109,6 +117,8 @@ export default class Sprite extends Component {

return {
position: 'absolute',
height: this.props.sourceHeight,
width: this.props.sourceWidth,
transform: [
{ translateX: left * -1 },
{ translateY: top * -1 },
Expand Down