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

Provide example how to implement pinch-zooming #132

Closed
MentalGear opened this issue Jan 13, 2017 · 6 comments
Closed

Provide example how to implement pinch-zooming #132

MentalGear opened this issue Jan 13, 2017 · 6 comments

Comments

@MentalGear
Copy link

As a mobile device user, I would expect pinch to zoom to work.
As tested on iOS 9, pinch to zoom is not working.

Also, when using the zoom slider on mobile, the image keeps "jumping" when adjusting zoom levels after dragging the picture.

Hint: Hammer.js is a great touch library to get pinch zoom to work !

@mosch
Copy link
Owner

mosch commented Jan 16, 2017

Zooming is up to the user of react-avatar-editor. We like to keep this simple and small. However we could provide a react-avatar-editor-pinch component that wraps this one and adds support for pinch

@mosch
Copy link
Owner

mosch commented Feb 6, 2017

PR for extra component welcome!

@mosch mosch changed the title Pinch to Zoom not working / Zoom jumpy with zoom Slider Provide example how to implement pinch-zooming Nov 25, 2017
@innoist
Copy link

innoist commented Jan 2, 2018

I was able to get the Pinch Zoom working by using react-hammer library.
So my component looks like this now

  onPinchOut = (e) => {
    console.log('onPinchOut;', e);
      this.setState({ profileImageDroppedScale: this.state.profileImageDroppedScale + 0.1 }) //initial value of 1
   }
  onPinchIn = (e) => {
        this.setState({ profileImageDroppedScale: this.state.profileImageDroppedScale - 0.1 })
    }

//by default pinch is disabled for react-hammer
let options = {
      recognizers: {
        pinch: { enable: true }
      }
    };

//Adding hammer component for touch support

    <Hammer options={options} onPinchIn={this.onPinchIn} onPinchOut={this.onPinchOut}   >
        <div>
          <AvatarEditor image={this.props.profileImageDropped} width={640} height={640} border={20} ref="avatar" scale={this.state.profileImageDroppedScale}
            rotate={this.state.rotate}
          />
        </div>
      </Hammer>

it is now working smoothly on touch screens.

@stale
Copy link

stale bot commented Jan 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 24, 2019
@stale stale bot closed this as completed Jan 31, 2019
@serabakpak
Copy link

serabakpak commented Feb 16, 2022

react-hammerjs worked great with older versions of React but it doesn't provide support for React 17. Looks like it isn't actively maintained :(.

Has anyone gotten an alternative way to work with React 17?

@mosch
Copy link
Owner

mosch commented Feb 18, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants