add zoom step to minimap
This commit is contained in:
@@ -67,7 +67,8 @@ function MiniMap({
|
|||||||
pannable = false,
|
pannable = false,
|
||||||
zoomable = false,
|
zoomable = false,
|
||||||
ariaLabel = 'React Flow mini map',
|
ariaLabel = 'React Flow mini map',
|
||||||
inversePan = false
|
inversePan = false,
|
||||||
|
zoomStep = 10
|
||||||
}: MiniMapProps) {
|
}: MiniMapProps) {
|
||||||
const store = useStoreApi();
|
const store = useStoreApi();
|
||||||
const svg = useRef<SVGSVGElement>(null);
|
const svg = useRef<SVGSVGElement>(null);
|
||||||
@@ -107,7 +108,7 @@ function MiniMap({
|
|||||||
const pinchDelta =
|
const pinchDelta =
|
||||||
-event.sourceEvent.deltaY *
|
-event.sourceEvent.deltaY *
|
||||||
(event.sourceEvent.deltaMode === 1 ? 0.05 : event.sourceEvent.deltaMode ? 1 : 0.002) *
|
(event.sourceEvent.deltaMode === 1 ? 0.05 : event.sourceEvent.deltaMode ? 1 : 0.002) *
|
||||||
10;
|
zoomStep;
|
||||||
const zoom = transform[2] * Math.pow(2, pinchDelta);
|
const zoom = transform[2] * Math.pow(2, pinchDelta);
|
||||||
|
|
||||||
d3Zoom.scaleTo(d3Selection, zoom);
|
d3Zoom.scaleTo(d3Selection, zoom);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export type MiniMapProps<NodeData = any> = Omit<HTMLAttributes<SVGSVGElement>, '
|
|||||||
zoomable?: boolean;
|
zoomable?: boolean;
|
||||||
ariaLabel?: string | null;
|
ariaLabel?: string | null;
|
||||||
inversePan?: boolean;
|
inversePan?: boolean;
|
||||||
|
zoomStep?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface MiniMapNodeProps {
|
export interface MiniMapNodeProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user