mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-27 18:24:11 +00:00
[Refactor] Move resetView to litegraphService (#2456)
This commit is contained in:
@@ -193,6 +193,14 @@ export class ComfyApp {
|
||||
return isImageNode(node)
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the canvas view to the default
|
||||
* @deprecated Use {@link useLitegraphService().resetView} instead
|
||||
*/
|
||||
resetView() {
|
||||
useLitegraphService().resetView()
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.vueAppReady = false
|
||||
this.ui = new ComfyUI(this)
|
||||
@@ -1805,12 +1813,6 @@ export class ComfyApp {
|
||||
}
|
||||
}
|
||||
|
||||
resetView() {
|
||||
app.canvas.ds.scale = 1
|
||||
app.canvas.ds.offset = [0, 0]
|
||||
app.graph.setDirtyCanvas(true, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory allocated to image preview blobs for a specific node, by revoking the URLs associated with them.
|
||||
* @param nodeId ID of the node to revoke all preview images of
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @ts-strict-ignore
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useLitegraphService } from '@/services/litegraphService'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
import { useSettingStore } from '@/stores/settingStore'
|
||||
import { useWorkspaceStore } from '@/stores/workspaceStore'
|
||||
@@ -609,7 +610,7 @@ export class ComfyUI {
|
||||
) {
|
||||
app.clean()
|
||||
app.graph.clear()
|
||||
app.resetView()
|
||||
useLitegraphService().resetView()
|
||||
api.dispatchCustomEvent('graphCleared')
|
||||
}
|
||||
}
|
||||
@@ -622,7 +623,7 @@ export class ComfyUI {
|
||||
!useSettingStore().get('Comfy.ConfirmClear') ||
|
||||
confirm('Load default workflow?')
|
||||
) {
|
||||
app.resetView()
|
||||
useLitegraphService().resetView()
|
||||
await app.loadGraphData()
|
||||
}
|
||||
}
|
||||
@@ -631,7 +632,7 @@ export class ComfyUI {
|
||||
id: 'comfy-reset-view-button',
|
||||
textContent: 'Reset View',
|
||||
onclick: async () => {
|
||||
app.resetView()
|
||||
useLitegraphService().resetView()
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user