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

[FIX] ImageViewer not recognising gestures after zoomed #2261

Merged
merged 2 commits into from
Jul 8, 2020
Merged
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
23 changes: 18 additions & 5 deletions app/presentation/ImageViewer/ImageViewer.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,21 @@ function bouncy(
const WIDTH = 300;
const HEIGHT = 300;

class Image extends React.PureComponent {
static propTypes = {
imageComponentType: PropTypes.string
}

render() {
const { imageComponentType } = this.props;

const Component = ImageComponent(imageComponentType);

return <Component {...this.props} />;
}
}
const AnimatedImage = Animated.createAnimatedComponent(Image);

// it was picked from https://github.com/software-mansion/react-native-reanimated/tree/master/Example/imageViewer
// and changed to use FastImage animated component
export class ImageViewer extends React.Component {
Expand Down Expand Up @@ -386,12 +401,9 @@ export class ImageViewer extends React.Component {

render() {
const {
uri, width, height, theme, imageComponentType, ...props
uri, width, height, imageComponentType, theme, ...props
} = this.props;

const Component = ImageComponent(imageComponentType);
const AnimatedFastImage = Animated.createAnimatedComponent(Component);

// The below two animated values makes it so that scale appears to be done
// from the top left corner of the image view instead of its center. This
// is required for the "scale focal point" math to work correctly
Expand All @@ -416,7 +428,7 @@ export class ImageViewer extends React.Component {
onGestureEvent={this._onPanEvent}
onHandlerStateChange={this._onPanEvent}
>
<AnimatedFastImage
<AnimatedImage
style={[
styles.image,
{
Expand All @@ -435,6 +447,7 @@ export class ImageViewer extends React.Component {
]
}
]}
imageComponentType={imageComponentType}
resizeMode='contain'
source={{ uri }}
{...props}
Expand Down