feat(core): expose wheelDelta utility (#1918)
* feat(core): expose wheelDelta utility Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add * fix(minimap): apply wheel delta to zoom Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import { PanOnScrollMode } from '../../types'
|
||||
import { useKeyPress } from '../../composables/useKeyPress'
|
||||
import { useVueFlow } from '../../composables/useVueFlow'
|
||||
import { useResizeHandler } from '../../composables/useResizeHandler'
|
||||
import { clamp, isMacOs, warn } from '../../utils'
|
||||
import { clamp, isMacOs, warn, wheelDelta } from '../../utils'
|
||||
import Pane from '../Pane/Pane.vue'
|
||||
import Transform from './Transform.vue'
|
||||
|
||||
@@ -380,12 +380,6 @@ function isRightClickPan(pan: boolean | number[], usedButton: number) {
|
||||
return usedButton === 2 && Array.isArray(pan) && pan.includes(2)
|
||||
}
|
||||
|
||||
function wheelDelta(event: any) {
|
||||
const factor = event.ctrlKey && isMacOs() ? 10 : 1
|
||||
|
||||
return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) * factor
|
||||
}
|
||||
|
||||
function viewChanged(prevViewport: ViewportTransform, eventTransform: ZoomTransform) {
|
||||
return (
|
||||
(prevViewport.x !== eventTransform.x && !Number.isNaN(eventTransform.x)) ||
|
||||
|
||||
@@ -48,6 +48,7 @@ export {
|
||||
getBoundsofRects,
|
||||
connectionExists,
|
||||
clamp,
|
||||
wheelDelta,
|
||||
} from './utils/graph'
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ import type {
|
||||
XYPosition,
|
||||
XYZPosition,
|
||||
} from '../types'
|
||||
import { isDef, snapPosition, warn } from '.'
|
||||
import { isDef, isMacOs, snapPosition, warn } from '.'
|
||||
|
||||
export function nodeToRect(node: GraphNode): Rect {
|
||||
return {
|
||||
@@ -504,3 +504,9 @@ export function getMarkerId(marker: EdgeMarkerType | undefined, vueFlowId?: stri
|
||||
.map((key) => `${key}=${marker[<keyof EdgeMarkerType>key]}`)
|
||||
.join('&')}`
|
||||
}
|
||||
|
||||
export function wheelDelta(event: any) {
|
||||
const factor = event.ctrlKey && isMacOs() ? 10 : 1
|
||||
|
||||
return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) * factor
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user