refactor(general): cleanup
This commit is contained in:
@@ -7,7 +7,7 @@ type ApplyChanges<ItemType, ChangesType> = (changes: ChangesType[], items: ItemT
|
||||
type OnChange<ChangesType> = (changes: ChangesType[]) => void;
|
||||
|
||||
// returns a hook that can be used liked this:
|
||||
// const [nodes, setNodes, onNodesChange] = useNodesState(intialNodes);
|
||||
// const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
|
||||
function createUseItemsState<ItemType, ChangesType>(
|
||||
applyChangesFunction: ApplyChanges<ItemType, ChangesType>
|
||||
): (initialItems: ItemType[]) => [ItemType[], Dispatch<SetStateAction<ItemType[]>>, OnChange<ChangesType>] {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useRef } from 'react';
|
||||
|
||||
import { pointToRendererPoint } from '../utils/graph';
|
||||
import { useStoreApi } from '../store';
|
||||
import useZoomPanHelper from './useZoomPanHelper';
|
||||
import useZoomPanHelper from '../hooks/useZoomPanHelper';
|
||||
import { OnPaneReady, XYPosition, Node, Edge, FlowExportObject } from '../types';
|
||||
|
||||
function useOnPaneReadyHandler(onPaneReady: OnPaneReady<any> | undefined) {
|
||||
|
||||
@@ -80,11 +80,11 @@ const useZoomPanHelper = (): ZoomPanHelperFunctions => {
|
||||
},
|
||||
setCenter: (x, y, options) => {
|
||||
const { width, height, maxZoom } = store.getState();
|
||||
|
||||
const nextZoom = typeof options?.zoom !== 'undefined' ? options.zoom : maxZoom;
|
||||
const centerX = width / 2 - x * nextZoom;
|
||||
const centerY = height / 2 - y * nextZoom;
|
||||
const transform = zoomIdentity.translate(centerX, centerY).scale(nextZoom);
|
||||
|
||||
d3Zoom.transform(getTransition(d3Selection, options?.duration), transform);
|
||||
},
|
||||
fitBounds: (bounds, options) => {
|
||||
|
||||
Reference in New Issue
Block a user