Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegating all possible props to ViewTransformer #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
11 changes: 5 additions & 6 deletions library/TransformableImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,20 @@ export default class TransformableImage extends Component {
}
}

const viewTransformerDelegation = Object.keys(ViewTransformer.propTypes).reduce(
(acc, prop) => (this.props[prop] ? { ...acc, [prop]: this.props[prop] } : acc), {}
);

return (
<ViewTransformer
ref='viewTransformer'
key={'viewTransformer#' + this.state.keyAccumulator} //when image source changes, we should use a different node to avoid reusing previous transform state
enableTransform={this.props.enableTransform && this.state.imageLoaded} //disable transform until image is loaded
enableScale={this.props.enableScale}
enableTranslate={this.props.enableTranslate}
enableResistance={true}
onTransformGestureReleased={this.props.onTransformGestureReleased}
onViewTransformed={this.props.onViewTransformed}
onSingleTapConfirmed={this.props.onSingleTapConfirmed}
maxScale={maxScale}
contentAspectRatio={contentAspectRatio}
onLayout={this.onLayout.bind(this)}
{...viewTransformerDelegation}
enableTransform={this.props.enableTransform && this.state.imageLoaded} //disable transform until image is loaded
style={this.props.style}>
<Image
{...this.props}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"homepage": "https://github.com/ldn0x7dc/react-native-transformable-image#readme",
"dependencies": {
"react-native-view-transformer": "0.0.28"
"react-native-view-transformer": "git://github.com/ldn0x7dc/react-native-view-transformer#f7e028b6566022deac4e523052e74c2c63a4af7e"
}
}