implement store reset
This commit is contained in:
@@ -362,13 +362,8 @@ export function createStore(signals: StoreSignals): SvelteFlowStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
store.selectionRect = null;
|
|
||||||
store.selectionRectMode = null;
|
|
||||||
|
|
||||||
store.resetStoreValues();
|
store.resetStoreValues();
|
||||||
|
|
||||||
unselectNodesAndEdges();
|
unselectNodesAndEdges();
|
||||||
cancelConnection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const storeWithActions = Object.assign(store, {
|
const storeWithActions = Object.assign(store, {
|
||||||
|
|||||||
@@ -236,7 +236,6 @@ export const getInitialStore = (signals: StoreSignals) => {
|
|||||||
|
|
||||||
// _viewport is the internal viewport.
|
// _viewport is the internal viewport.
|
||||||
// when binding to viewport, we operate on signals.viewport instead
|
// when binding to viewport, we operate on signals.viewport instead
|
||||||
initial: boolean = true;
|
|
||||||
_viewport: Viewport = $state(signals.props.initialViewport ?? { x: 0, y: 0, zoom: 1 });
|
_viewport: Viewport = $state(signals.props.initialViewport ?? { x: 0, y: 0, zoom: 1 });
|
||||||
get viewport() {
|
get viewport() {
|
||||||
return signals.viewport ?? this._viewport;
|
return signals.viewport ?? this._viewport;
|
||||||
@@ -361,7 +360,17 @@ export const getInitialStore = (signals: StoreSignals) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetStoreValues() {
|
resetStoreValues() {
|
||||||
// TODO: reset all store values here
|
this.dragging = false;
|
||||||
|
this.selectionRect = null;
|
||||||
|
this.selectionRectMode = null;
|
||||||
|
this.selectionKeyPressed = false;
|
||||||
|
this.multiselectionKeyPressed = false;
|
||||||
|
this.deleteKeyPressed = false;
|
||||||
|
this.panActivationKeyPressed = false;
|
||||||
|
this.zoomActivationKeyPressed = false;
|
||||||
|
this._connection = initialConnection;
|
||||||
|
this.clickConnectStartHandle = null;
|
||||||
|
this.viewport = signals.props.initialViewport ?? { x: 0, y: 0, zoom: 1 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new SvelteFlowStore();
|
return new SvelteFlowStore();
|
||||||
|
|||||||
Reference in New Issue
Block a user