@@ -76,6 +76,8 @@ const shouldPanOnScroll = toRef(() => panKeyPressed.value || panOnScroll.value)
76
76
77
77
const isSelecting = toRef (() => selectionKeyPressed .value || (selectionKeyCode .value === true && shouldPanOnDrag .value !== true ))
78
78
79
+ const connectionInProgress = toRef (() => connectionStartHandle .value !== null )
80
+
79
81
onMounted (() => {
80
82
if (! viewportRef .value ) {
81
83
warn (' Viewport element is missing' )
@@ -163,6 +165,7 @@ onMounted(() => {
163
165
const zoomScroll = zoomKeyPressed .value || zoomOnScroll .value
164
166
const pinchZoom = zoomOnPinch .value && event .ctrlKey
165
167
const eventButton = (event as MouseEvent ).button
168
+ const isWheelEvent = event .type === ' wheel'
166
169
167
170
if (
168
171
eventButton === 1 &&
@@ -182,30 +185,35 @@ onMounted(() => {
182
185
return false
183
186
}
184
187
188
+ // we want to disable pinch-zooming while making a connection
189
+ if (connectionInProgress .value && ! isWheelEvent ) {
190
+ return false
191
+ }
192
+
185
193
// if zoom on double click is disabled, we prevent the double click event
186
194
if (! zoomOnDoubleClick .value && event .type === ' dblclick' ) {
187
195
return false
188
196
}
189
197
190
198
// if the target element is inside an element with the nowheel class, we prevent zooming
191
- if (isWrappedWithClass (event , noWheelClassName .value ) && event . type === ' wheel ' ) {
199
+ if (isWrappedWithClass (event , noWheelClassName .value ) && isWheelEvent ) {
192
200
return false
193
201
}
194
202
195
203
// if the target element is inside an element with the nopan class, we prevent panning
196
204
if (
197
205
isWrappedWithClass (event , noPanClassName .value ) &&
198
- (event . type !== ' wheel ' || (shouldPanOnScroll .value && event . type === ' wheel ' && ! zoomKeyPressed .value ))
206
+ (! isWheelEvent || (shouldPanOnScroll .value && isWheelEvent && ! zoomKeyPressed .value ))
199
207
) {
200
208
return false
201
209
}
202
210
203
- if (! zoomOnPinch .value && event .ctrlKey && event . type === ' wheel ' ) {
211
+ if (! zoomOnPinch .value && event .ctrlKey && isWheelEvent ) {
204
212
return false
205
213
}
206
214
207
215
// when there is no scroll handling enabled, we prevent all wheel events
208
- if (! zoomScroll && ! shouldPanOnScroll .value && ! pinchZoom && event . type === ' wheel ' ) {
216
+ if (! zoomScroll && ! shouldPanOnScroll .value && ! pinchZoom && isWheelEvent ) {
209
217
return false
210
218
}
211
219
@@ -242,7 +250,7 @@ onMounted(() => {
242
250
eventButton <= 1
243
251
244
252
// default filter for d3-zoom
245
- return (! event .ctrlKey || panKeyPressed .value || event . type === ' wheel ' ) && buttonAllowed
253
+ return (! event .ctrlKey || panKeyPressed .value || isWheelEvent ) && buttonAllowed
246
254
})
247
255
248
256
watch (
@@ -414,7 +422,7 @@ export default {
414
422
:is-selecting =" isSelecting"
415
423
:selection-key-pressed =" selectionKeyPressed"
416
424
:class =" {
417
- connecting: !!connectionStartHandle ,
425
+ connecting: connectionInProgress ,
418
426
dragging: paneDragging,
419
427
draggable: panOnDrag === true || (Array.isArray(panOnDrag) && panOnDrag.includes(0)),
420
428
}"
0 commit comments