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

Way to block dragging completely and allow only zooming? #67

Open
hy2850 opened this issue Mar 30, 2023 · 2 comments
Open

Way to block dragging completely and allow only zooming? #67

hy2850 opened this issue Mar 30, 2023 · 2 comments

Comments

@hy2850
Copy link

hy2850 commented Mar 30, 2023

Hello,
I only need the zooming functionality but there seems no way to block the dragging events and only allow zooming.
All the event listener props for drag events onDragStart/End/Update doesn't seem to provide a way to disable the event.
Is this supported at all? If not, can you suggest me an alternative?

Thanks in advance

@aminemohyeddine
Copy link

hello @hy2850 ,
declare a ref globally : const dragXY = useRef({})
inside onUpdate in the top add :
if (dragXY.current?.scale !== scale) {
dragXY.current = { x, scale, y }
}

update make3dTransformValue line to : make3dTransformValue({ x: dragXY.current?.x || x, y:dragXY.current?.y || y, scale })

i hope this will help , i'm stuck with a really complicated cases :'(

@retyui
Copy link
Owner

retyui commented Sep 6, 2023

I see, welcome to PR if you can fix it!

also you can try an alternative library: https://github.com/prc5/react-zoom-pan-pinch

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

3 participants