added nodeExtent to Svelte Flow and React Flow Provider
This commit is contained in:
@@ -37,7 +37,8 @@ export function createStore({
|
||||
width,
|
||||
height,
|
||||
fitView: fitViewOnCreate,
|
||||
nodeOrigin
|
||||
nodeOrigin,
|
||||
nodeExtent
|
||||
}: {
|
||||
nodes?: Node[];
|
||||
edges?: Edge[];
|
||||
@@ -45,6 +46,7 @@ export function createStore({
|
||||
height?: number;
|
||||
fitView?: boolean;
|
||||
nodeOrigin?: NodeOrigin;
|
||||
nodeExtent?: CoordinateExtent;
|
||||
}): SvelteFlowStore {
|
||||
const store = getInitialStore({
|
||||
nodes,
|
||||
@@ -52,7 +54,8 @@ export function createStore({
|
||||
width,
|
||||
height,
|
||||
fitView: fitViewOnCreate,
|
||||
nodeOrigin
|
||||
nodeOrigin,
|
||||
nodeExtent
|
||||
});
|
||||
|
||||
function setNodeTypes(nodeTypes: NodeTypes) {
|
||||
@@ -482,7 +485,8 @@ export function createStoreContext({
|
||||
width,
|
||||
height,
|
||||
fitView,
|
||||
nodeOrigin
|
||||
nodeOrigin,
|
||||
nodeExtent
|
||||
}: {
|
||||
nodes?: Node[];
|
||||
edges?: Edge[];
|
||||
@@ -490,8 +494,9 @@ export function createStoreContext({
|
||||
height?: number;
|
||||
fitView?: boolean;
|
||||
nodeOrigin?: NodeOrigin;
|
||||
nodeExtent?: CoordinateExtent;
|
||||
}) {
|
||||
const store = createStore({ nodes, edges, width, height, fitView, nodeOrigin });
|
||||
const store = createStore({ nodes, edges, width, height, fitView, nodeOrigin, nodeExtent });
|
||||
|
||||
setContext(key, {
|
||||
getStore: () => store
|
||||
|
||||
@@ -75,7 +75,8 @@ export const getInitialStore = ({
|
||||
width,
|
||||
height,
|
||||
fitView,
|
||||
nodeOrigin
|
||||
nodeOrigin,
|
||||
nodeExtent
|
||||
}: {
|
||||
nodes?: Node[];
|
||||
edges?: Edge[];
|
||||
@@ -83,17 +84,23 @@ export const getInitialStore = ({
|
||||
height?: number;
|
||||
fitView?: boolean;
|
||||
nodeOrigin?: NodeOrigin;
|
||||
nodeExtent?: CoordinateExtent;
|
||||
}) => {
|
||||
const nodeLookup: NodeLookup = new Map();
|
||||
const parentLookup = new Map();
|
||||
const connectionLookup = new Map();
|
||||
const edgeLookup = new Map();
|
||||
|
||||
const storeNodeOrigin = nodeOrigin ?? [0, 0];
|
||||
const storeNodeExtent = nodeExtent ?? infiniteExtent;
|
||||
|
||||
adoptUserNodes(nodes, nodeLookup, parentLookup, {
|
||||
nodeExtent: storeNodeExtent,
|
||||
nodeOrigin: storeNodeOrigin,
|
||||
elevateNodesOnSelect: false,
|
||||
checkEquality: false
|
||||
});
|
||||
const connectionLookup = new Map();
|
||||
const edgeLookup = new Map();
|
||||
|
||||
updateConnectionLookup(connectionLookup, edgeLookup, edges);
|
||||
|
||||
let viewport: Viewport = { x: 0, y: 0, zoom: 1 };
|
||||
@@ -121,7 +128,7 @@ export const getInitialStore = ({
|
||||
maxZoom: writable<number>(2),
|
||||
nodeOrigin: writable<NodeOrigin>(storeNodeOrigin),
|
||||
nodeDragThreshold: writable<number>(1),
|
||||
nodeExtent: writable<CoordinateExtent>(infiniteExtent),
|
||||
nodeExtent: writable<CoordinateExtent>(storeNodeExtent),
|
||||
translateExtent: writable<CoordinateExtent>(infiniteExtent),
|
||||
autoPanOnNodeDrag: writable<boolean>(true),
|
||||
autoPanOnConnect: writable<boolean>(true),
|
||||
|
||||
Reference in New Issue
Block a user