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

ScrollView pinch zoom in and out functionality not working for android #20154

Closed
3 tasks
k0m00xv opened this issue Jul 11, 2018 · 8 comments
Closed
3 tasks

ScrollView pinch zoom in and out functionality not working for android #20154

k0m00xv opened this issue Jul 11, 2018 · 8 comments
Labels
Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@k0m00xv
Copy link

k0m00xv commented Jul 11, 2018

Environment

Environment:
OS: macOS High Sierra 10.13.5
Node: 9.10.1
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.4.1 Build version 9F2000
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: ^16.3.1 => 16.4.1
react-native: ^0.52.0 => 0.52.3

Description

I am using scrollView' maximumZoomScale and minimumZoomScale properties to zoom in and out of an SVG. It works as expected with ios but with android it doesn't respond to the pinch gesture, Please help!

Reproducible Demo

screen shot 2018-07-11 at 7 51 07 pm

@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Jul 26, 2018
@react-native-bot
Copy link
Collaborator

I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

@LeathanTeal
Copy link

@k0m00xv I am running into this same issue. Did you ever find a solution?

@JensDebergh
Copy link

@k0m00xv @LeathanTeal maximumZoomScale & minimumZoomScale are iOS only. ScrollViews on android do not support zoomScales.

@KrMilind
Copy link

KrMilind commented Sep 3, 2018

@JensDebergh Yeah, I realized that the hard way, but I still want to know if there is a pinch zoom option in react native which behaves similarly on both ios and Android platforms.
@LeathanTeal Not really. I searched a lot online, I tried using react-native-pinch-zoom-responder
and react-native-pinch-zoom-view components but didn't really work as expected.

@Darker
Copy link

Darker commented Sep 11, 2018

Another React issue that is closed instead of solved. Why even have an issue tracker if you do not care about issues that people report?

@JensDebergh
Copy link

@Darker React Native tries to bridge the gap between Android and iOS. Only iOS supports maximumZoomScale and minimumZoomScale because they support it natively on iOS.

Android on the other hand does not have native support for these properties. React native is unable to support it because the native platform doesn't have support for it.

So yes, I do understand why they are closing this issue. The only thing they could do is provide a decent explanation.

It is possible to add a zoom functionality in react-native using a ScrollView in a View which has a PanResponder attached to it.

Hope this helps:

react-native-camera/react-native-camera#1282

import React, { Component } from "react";
import { View, PanResponder, Dimensions } from "react-native";

class ZoomView extends Component {
  constructor(props) {
    super(props)
    this._panResponder = PanResponder.create({
      onPanResponderMove: (e, { dy }) => {
        const { height: windowHeight } = Dimensions.get(`window`)
        return this.props.onZoomProgress(
          Math.min(Math.max(dy * -1 / windowHeight, 0), 0.5),
        )
      },
      onMoveShouldSetPanResponder: (ev, { dx }) => {
        return dx !== 0
      },
      onPanResponderGrant: () => {
        return this.props.onZoomStart()
      },
      onPanResponderRelease: () => {
        return this.props.onZoomEnd()
      },
    })
  }
  render() {
    return (
      <View
        style={{ flex: 1, width: `100%` }}
        {...this._panResponder.panHandlers}
      >
        {this.props.children}
      </View>
    )
  }
}

@KrMilind
Copy link

@JensDebergh But in android, we have seen the zooming functionality with react-native implementation, so why not(expect the react native team to) develop a react native component which provides the same functionality on both platforms. Since zooming is a feature that almost all apps end up needing. It is just good support if they are able to come up with some component that provides zooming functionality on both platforms

@KrMilind
Copy link

Also, I did find a graceful way of handling pinch zoom. There is this component https://www.npmjs.com/package/react-native-image-pan-zoom which allows you to control the pinch zooming functionality to a certain level. And it is not perfect, but was still able to solve my issue. Hope it helps anyone out there looking for a solution.

darkbasic added a commit to darkbasic/react-native-website that referenced this issue Mar 24, 2019
charpeni pushed a commit to facebook/react-native-website that referenced this issue Apr 7, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Jul 26, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants