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

Do not scale child elements

Open hellozyemlya opened this issue 3 years ago • 3 comments

Is that possible to skip scaling for child elements? I have some kind of map, and I don't want to scale icons or text on it.

Thanks.

hellozyemlya avatar Dec 23 '21 19:12 hellozyemlya

Hello @hellozyemlya ser 👋

I have the same issue (map element with some text/buttons over it). Did you maybe find a solution or alternative library to this one? Save me... 🤣

josip-volarevic avatar Feb 10 '22 13:02 josip-volarevic

@Volki312 @hellozyemlya Hi! You can always use CSS transform property:

{({ state: { scale }, ...transformProps }) => (
       <TransformComponent>
          <div className="content">
            <img src={notScalableIconSrc} className="not-scalable-image" style={{ transform: `scale(${1 / scale})`  }} />
            <img src={scalableMapSrc} className="scalable-image" />
          </div>
        </TransformComponent>
 )}

Using scale this way it will always invert the parent's scale and stay the same size

drumwithrum avatar Feb 14 '22 12:02 drumwithrum

@drumwithrum ah, makes so much sense...

Thanks a lot ser. Here, have this in return ༼ つ ◕_◕ ༽つ🍌

josip-volarevic avatar Feb 15 '22 09:02 josip-volarevic

Added KeepScale component 🚀

prc5 avatar Feb 27 '23 16:02 prc5