Skip to content

Commit

Permalink
fix(core): if selection key code is true prevent pan on drag on left …
Browse files Browse the repository at this point in the history
…mouse btn

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
  • Loading branch information
bcakmakoglu committed Nov 1, 2024
1 parent 00cff79 commit cc2eb99
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/core/src/container/Viewport/Viewport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ onMounted(() => {
return false
}
// if selection key code is true and panOnDrag tries to use left mouse button we prevent it
if (selectionKeyCode.value === true && Array.isArray(panOnDrag.value) && panOnDrag.value.includes(0) && eventButton === 0) {
return false
}
// if the pane is only movable using allowed clicks
if (
Array.isArray(shouldPanOnDrag.value) &&
Expand All @@ -230,16 +235,12 @@ 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 =
leftMouseBtnPanAllowed &&
((Array.isArray(panOnDrag.value) && panOnDrag.value.includes(eventButton)) ||
(selectionKeyCode.value === true && Array.isArray(panOnDrag.value) && !panOnDrag.value.includes(0)) ||
!eventButton ||
eventButton <= 1)
(Array.isArray(shouldPanOnDrag.value) && shouldPanOnDrag.value.includes(eventButton)) ||
(selectionKeyCode.value === true && Array.isArray(shouldPanOnDrag.value) && !shouldPanOnDrag.value.includes(0)) ||
!eventButton ||
eventButton <= 1
// default filter for d3-zoom
return (!event.ctrlKey || event.type === 'wheel') && buttonAllowed
Expand Down

0 comments on commit cc2eb99

Please sign in to comment.