mirror of
https://github.com/langgenius/dify.git
synced 2026-08-03 11:46:37 +08:00
fix gesture zoom in
This commit is contained in:
parent
7fc98b2183
commit
ff8d5ac4b5
@ -314,6 +314,37 @@ export const Workflow: FC<WorkflowProps> = memo(({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Prevent browser zoom interactions from hijacking gestures meant for the workflow canvas
|
||||||
|
useEffect(() => {
|
||||||
|
const preventBrowserZoom = (event: WheelEvent) => {
|
||||||
|
if (!isCommentPreviewHovering)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (event.ctrlKey || event.metaKey)
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
const preventGestureZoom = (event: Event) => {
|
||||||
|
if (!isCommentPreviewHovering)
|
||||||
|
return
|
||||||
|
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('wheel', preventBrowserZoom, { passive: false })
|
||||||
|
const gestureEvents: Array<'gesturestart' | 'gesturechange' | 'gestureend'> = ['gesturestart', 'gesturechange', 'gestureend']
|
||||||
|
gestureEvents.forEach((eventName) => {
|
||||||
|
window.addEventListener(eventName, preventGestureZoom, { passive: false })
|
||||||
|
})
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('wheel', preventBrowserZoom)
|
||||||
|
gestureEvents.forEach((eventName) => {
|
||||||
|
window.removeEventListener(eventName, preventGestureZoom)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [isCommentPreviewHovering])
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleNodeDragStart,
|
handleNodeDragStart,
|
||||||
handleNodeDrag,
|
handleNodeDrag,
|
||||||
@ -536,7 +567,7 @@ export const Workflow: FC<WorkflowProps> = memo(({
|
|||||||
edgesFocusable={!nodesReadOnly}
|
edgesFocusable={!nodesReadOnly}
|
||||||
panOnScroll={false}
|
panOnScroll={false}
|
||||||
panOnDrag={controlMode === ControlMode.Hand}
|
panOnDrag={controlMode === ControlMode.Hand}
|
||||||
zoomOnPinch={!isCommentPreviewHovering}
|
zoomOnPinch={true}
|
||||||
zoomOnScroll={true}
|
zoomOnScroll={true}
|
||||||
zoomOnDoubleClick={true}
|
zoomOnDoubleClick={true}
|
||||||
isValidConnection={isValidConnection}
|
isValidConnection={isValidConnection}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user