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

Expose state variables in useControls hook and on transformWrapper ref object #442

Open
Andrii-Vovk opened this issue Dec 28, 2023 · 1 comment

Comments

@Andrii-Vovk
Copy link

Is your feature request related to a problem? Please describe.
The library lacks some common exposed variables, that would be hugely useful for:
Disabling panning, zoom on conditions;
Doing actions when items are zoomed in

Describe the solution you'd like
Expose additional variables, like isPanning, isZoomed, scale etc. in the useControls Hook and on the ref object.
It seems that ts types already include those in a state field, but it is only populated in the events, and not on the main ref obect in this configuration:

// transformWrapperRef.current?.state object is always undefined here
  const transformWrapperRef = useRef<ReactZoomPanPinchRef | null>(null);

  <TransformWrapper
    ref={transformWrapperRef}
  >
    <TransformComponent>
        <img
          src={image}
        />
    </TransformComponent>
  </TransformWrapper>

Describe alternatives you've considered
Using event handlers like onPanning and onZoom to set a boolean state for isZoomedIn. Requires additional event throttling, and, to my mind is generally a worse solution. (because onZoom seems to not always fire on first double tap, and isPanning is firing every pixel moved)

@rluttikhuizen
Copy link

Hello,

It would be really useful to have the state field populated on the ref object.

Thanks,

Ronald

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

No branches or pull requests

2 participants