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

scale calculation is not fixed 3.3.0

Open cheolhow opened this issue 1 year ago • 5 comments

Describe the bug

https://github.com/BetterTyped/react-zoom-pan-pinch/pull/367 3.0.7 works fine, but 3.3.0 doesn't work again.

To Reproduce When initialScale is 1, it does not increase by 0.5 when the zoomIn(0.5) is executed.

cheolhow avatar Oct 24 '23 01:10 cheolhow

I got the same issue

vishwakarmanikhil avatar Jan 08 '24 13:01 vishwakarmanikhil

do you have any idea?

hokimtam avatar Mar 19 '24 04:03 hokimtam

I don't know how to fix this bug. So I downgraded to version 3.0.7, which is the version that works.

cheolhow avatar Mar 19 '24 04:03 cheolhow

A lord trick for this, I manual set scale for my component using ref. I hope it help you.

const setScale = (newScale: number) => { if (transformComponentRef.current) { const { setTransform, instance } = transformComponentRef.current; setTransform( instance?.transformState?.positionX || 0, instance?.transformState?.positionY || 0, newScale, 200, "easeOut" ); } };

hokimtam avatar Mar 19 '24 07:03 hokimtam

I encountered the same issue and I found out you just need to set smooth attribute to false to have constant step. Hope this helps.

 <TransformWrapper smooth={false} />

plwai avatar Apr 12 '24 06:04 plwai