react-zoom-pan-pinch icon indicating copy to clipboard operation
react-zoom-pan-pinch copied to clipboard

Step option for pinch does not seem to work

Open okanji opened this issue 10 months ago • 3 comments

Describe the bug I can't seem to change the step for a pinch event, adding the step option seems to make no difference.

To Reproduce

use client";

import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";

export default function Gestures({ children }: { children: React.ReactNode }) {
  return (
    <TransformWrapper pinch={{ step: 20 }}>
      <TransformComponent
        contentStyle={{
          touchAction: "none",
          position: "fixed",
          width: "100vw",
          height: "100vh",
        }}
      >
        {children}
      </TransformComponent>
    </TransformWrapper>
  );
}

Expected behavior I expect the amount zoomed in for a pinch gesture to increase

Desktop (please complete the following information): Mac Next.js Chrome

okanji avatar Sep 06 '23 17:09 okanji

I'm experiencing this as well, along with a few other oddities that might be related:

When pinching, onPinchingStart() is not firing at all; however onZoomStart() is.

When wheel.activationKeys are supplied, pinching is also affected; i.e. pinching does not work without holding down the wheel activation keys.

FWIW I have my trackpad sensitivity set to max, and when comparing behaviour here to that of e.g. Google Maps, with one exaggerated pinch gesture I'm able to zoom in on Google Maps ~200%. With the same gesture using this plugin, I'm only able to zoom in ~30% — regardless of pinch.step.

Desktop macOS Arc

bradcerasani avatar Oct 05 '23 17:10 bradcerasani

I think the onPinch() only works if you're using mobile, in desktop when you use pinch gesture, it actually calls onWheel event

davidnguyen11 avatar Dec 01 '23 13:12 davidnguyen11

Just found out if you increase smoothStep , it will speed up pinch on trackpad

<TransformWrapper wheel={{ step: 0.9, smoothStep: 0.01 }}>

davidnguyen11 avatar Dec 04 '23 12:12 davidnguyen11