feat(svelte): reset store when component unmounts
This commit is contained in:
@@ -287,6 +287,15 @@ export function createStore(params: CreateStoreParams): SvelteFlowStore {
|
||||
updateConnection(initConnectionData);
|
||||
}
|
||||
|
||||
function reset() {
|
||||
store.fitViewOnInitDone.set(false);
|
||||
store.selectionRect.set(null);
|
||||
store.selectionRectMode.set(null);
|
||||
|
||||
resetSelectedElements();
|
||||
cancelConnection();
|
||||
}
|
||||
|
||||
return {
|
||||
// state
|
||||
...store,
|
||||
@@ -310,7 +319,8 @@ export function createStore(params: CreateStoreParams): SvelteFlowStore {
|
||||
addSelectedNodes,
|
||||
panBy,
|
||||
updateConnection,
|
||||
cancelConnection
|
||||
cancelConnection,
|
||||
reset
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ export type SvelteFlowStoreActions = {
|
||||
panBy: (delta: XYPosition) => void;
|
||||
updateConnection: (connection: Partial<ConnectionData>) => void;
|
||||
cancelConnection: () => void;
|
||||
reset(): void;
|
||||
};
|
||||
|
||||
export type SvelteFlowStoreState = typeof initialStoreState & {
|
||||
|
||||
Reference in New Issue
Block a user