Skip to content

Commit 18d103d

Browse files
authored
fix(minimap): use 1 as zoomstep for minimap and apply factor based on macOs (#1923)
* fix(minimap): use 1 as zoomstep for minimap and apply factor based on macOs Signed-off-by: braks <[email protected]> * refactor(core): expose isMacOs Signed-off-by: braks <[email protected]> * chore(changeset): add * chore(changeset): add --------- Signed-off-by: braks <[email protected]>
1 parent 0568ab7 commit 18d103d

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

.changeset/dull-swans-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": minor
3+
---
4+
5+
Expose `isMacOs` utility

.changeset/tender-geckos-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/minimap": patch
3+
---
4+
5+
Set zoomstep to 1 and apply factor based on macOs (zoomstep \* factor - 10 if macOs)

packages/core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export {
5151
wheelDelta,
5252
} from './utils/graph'
5353

54+
export { isMacOs } from './utils/general'
55+
5456
/**
5557
* @deprecated - Use store instance and call `applyChanges` with template-ref or the one received by `onPaneReady` instead
5658
* Intended for options API

packages/minimap/src/MiniMap.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
22
import type { CoordinateExtent, GraphNode, PanelPosition } from '@vue-flow/core'
3-
import { Panel, getBoundsofRects, getConnectedEdges, getRectOfNodes, useVueFlow, wheelDelta } from '@vue-flow/core'
3+
import { Panel, getBoundsofRects, getConnectedEdges, getRectOfNodes, isMacOs, useVueFlow, wheelDelta } from '@vue-flow/core'
44
import { zoom, zoomIdentity } from 'd3-zoom'
55
import type { D3ZoomEvent } from 'd3-zoom'
66
import { pointer, select } from 'd3-selection'
@@ -26,7 +26,7 @@ const {
2626
zoomable = false,
2727
ariaLabel = 'Vue Flow mini map',
2828
inversePan = false,
29-
zoomStep = 10,
29+
zoomStep = 1,
3030
offsetScale = 5,
3131
} = defineProps<MiniMapProps>()
3232
@@ -126,13 +126,14 @@ watchEffect(
126126
return
127127
}
128128
129+
const factor = event.sourceEvent.ctrlKey && isMacOs() ? 10 : 1
129130
const pinchDelta =
130131
-event.sourceEvent.deltaY *
131132
(event.sourceEvent.deltaMode === 1 ? 0.05 : event.sourceEvent.deltaMode ? 1 : 0.002) *
132133
zoomStep
133-
const zoom = viewport.value.zoom * 2 ** pinchDelta
134+
const nextZoom = viewport.value.zoom * 2 ** (pinchDelta * factor)
134135
135-
d3Zoom.value.scaleTo(d3Selection.value, zoom)
136+
d3Zoom.value.scaleTo(d3Selection.value, nextZoom)
136137
}
137138
138139
const panHandler = (event: D3ZoomEvent<HTMLDivElement, any>) => {

0 commit comments

Comments
 (0)