@@ -151,13 +151,14 @@ onMounted(() => {
151
151
}
152
152
})
153
153
154
- d3Zoom .filter ((event : MouseEvent ) => {
154
+ d3Zoom .filter ((event : MouseEvent | TouchEvent ) => {
155
155
const zoomScroll = zoomKeyPressed .value || zoomOnScroll .value
156
156
const pinchZoom = zoomOnPinch .value && event .ctrlKey
157
+ const eventButton = (event as MouseEvent ).button
157
158
158
159
if (
159
160
(shouldPanOnDrag .value === true || (Array .isArray (shouldPanOnDrag .value ) && shouldPanOnDrag .value .includes (1 ))) &&
160
- event . button === 1 &&
161
+ eventButton === 1 &&
161
162
event .type === ' mousedown' &&
162
163
((event .target as HTMLElement )?.closest (' .vue-flow__node' ) || (event .target as HTMLElement )?.closest (' .vue-flow__edge' ))
163
164
) {
@@ -201,6 +202,12 @@ onMounted(() => {
201
202
return false
202
203
}
203
204
205
+ // prevent zooming on mobile when using pinch and zoomOnPinch is disabled
206
+ if (! zoomOnPinch && event .type === ' touchstart' && (event as TouchEvent ).touches ?.length > 1 ) {
207
+ event .preventDefault () // if you manage to start with 2 touches, we prevent native zoom
208
+ return false
209
+ }
210
+
204
211
// if the pane is not movable, we prevent dragging it with mousestart or touchstart
205
212
if (! shouldPanOnDrag .value && (event .type === ' mousedown' || event .type === ' touchstart' )) {
206
213
return false
@@ -209,15 +216,15 @@ onMounted(() => {
209
216
// if the pane is only movable using allowed clicks
210
217
if (
211
218
Array .isArray (shouldPanOnDrag .value ) &&
212
- ! shouldPanOnDrag .value .includes (event . button ) &&
219
+ ! shouldPanOnDrag .value .includes (eventButton ) &&
213
220
(event .type === ' mousedown' || event .type === ' touchstart' )
214
221
) {
215
222
return false
216
223
}
217
224
218
225
// We only allow right clicks if pan on drag is set to right-click
219
226
const buttonAllowed =
220
- (Array .isArray (shouldPanOnDrag .value ) && shouldPanOnDrag .value .includes (event . button )) || ! event . button || event . button <= 1
227
+ (Array .isArray (shouldPanOnDrag .value ) && shouldPanOnDrag .value .includes (eventButton )) || ! eventButton || eventButton <= 1
221
228
222
229
// default filter for d3-zoom
223
230
return (! event .ctrlKey || event .type === ' wheel' ) && buttonAllowed
0 commit comments