Skip to content

Commit

Permalink
fix(core): allow pan on drag for other mouse btns if left is disabled
Browse files Browse the repository at this point in the history
Signed-off-by: braks <[email protected]>
  • Loading branch information
bcakmakoglu committed Nov 1, 2024
1 parent e51f08c commit 532a8f0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/core/src/container/Viewport/Viewport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ const selectionKeyPressed = useKeyPress(selectionKeyCode)
const zoomKeyPressed = useKeyPress(zoomActivationKeyCode)
const shouldPanOnDrag = toRef(() => !selectionKeyPressed.value && (panKeyPressed.value || panOnDrag.value))
const shouldPanOnDrag = toRef(
() =>
(!selectionKeyPressed.value || (selectionKeyPressed.value && selectionKeyCode.value === true)) &&
(panKeyPressed.value || panOnDrag.value),
)
const shouldPanOnScroll = toRef(() => panKeyPressed.value || panOnScroll.value)
Expand Down Expand Up @@ -226,9 +230,16 @@ onMounted(() => {
return false
}
const leftMouseBtnPanAllowed =
eventButton !== 0 || (selectionKeyCode.value === true && Array.isArray(panOnDrag.value) && !panOnDrag.value.includes(0))
// We only allow right clicks if pan on drag is set to right-click
const buttonAllowed =
(Array.isArray(shouldPanOnDrag.value) && shouldPanOnDrag.value.includes(eventButton)) || !eventButton || eventButton <= 1
leftMouseBtnPanAllowed &&
((Array.isArray(panOnDrag.value) && panOnDrag.value.includes(eventButton)) ||
(selectionKeyCode.value === true && Array.isArray(panOnDrag.value) && !panOnDrag.value.includes(0)) ||
!eventButton ||
eventButton <= 1)
// default filter for d3-zoom
return (!event.ctrlKey || event.type === 'wheel') && buttonAllowed
Expand Down

0 comments on commit 532a8f0

Please sign in to comment.