Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
f374ea71
"examples/vscode:/vscode.git/clone" did not exist on "3fd31eef518b73ee592f82435f3d370a716ead4f"
Unverified
Commit
f374ea71
authored
May 10, 2024
by
pythongosssss
Committed by
GitHub
May 10, 2024
Browse files
Setting for saving and restoring canvas position and zoom level (#3437)
parent
0fecfd2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
web/scripts/app.js
web/scripts/app.js
+35
-0
No files found.
web/scripts/app.js
View file @
f374ea71
...
@@ -262,6 +262,36 @@ export class ComfyApp {
...
@@ -262,6 +262,36 @@ export class ComfyApp {
})
})
);
);
}
}
#
addRestoreWorkflowView
()
{
const
serialize
=
LGraph
.
prototype
.
serialize
;
const
self
=
this
;
LGraph
.
prototype
.
serialize
=
function
()
{
const
workflow
=
serialize
.
apply
(
this
,
arguments
);
// Store the drag & scale info in the serialized workflow if the setting is enabled
if
(
self
.
enableWorkflowViewRestore
.
value
)
{
if
(
!
workflow
.
extra
)
{
workflow
.
extra
=
{};
}
workflow
.
extra
.
ds
=
{
scale
:
self
.
canvas
.
ds
.
scale
,
offset
:
self
.
canvas
.
ds
.
offset
,
};
}
else
if
(
workflow
.
extra
?.
ds
)
{
// Clear any old view data
delete
workflow
.
extra
.
ds
;
}
return
workflow
;
}
this
.
enableWorkflowViewRestore
=
this
.
ui
.
settings
.
addSetting
({
id
:
"
Comfy.EnableWorkflowViewRestore
"
,
name
:
"
Save and restore canvas position and zoom level in workflows
"
,
type
:
"
boolean
"
,
defaultValue
:
true
});
}
/**
/**
* Adds special context menu handling for nodes
* Adds special context menu handling for nodes
...
@@ -1505,6 +1535,7 @@ export class ComfyApp {
...
@@ -1505,6 +1535,7 @@ export class ComfyApp {
this
.
#
addProcessKeyHandler
();
this
.
#
addProcessKeyHandler
();
this
.
#
addConfigureHandler
();
this
.
#
addConfigureHandler
();
this
.
#
addApiUpdateHandlers
();
this
.
#
addApiUpdateHandlers
();
this
.
#
addRestoreWorkflowView
();
this
.
graph
=
new
LGraph
();
this
.
graph
=
new
LGraph
();
...
@@ -1805,6 +1836,10 @@ export class ComfyApp {
...
@@ -1805,6 +1836,10 @@ export class ComfyApp {
try
{
try
{
this
.
graph
.
configure
(
graphData
);
this
.
graph
.
configure
(
graphData
);
if
(
this
.
enableWorkflowViewRestore
.
value
&&
graphData
.
extra
?.
ds
)
{
this
.
canvas
.
ds
.
offset
=
graphData
.
extra
.
ds
.
offset
;
this
.
canvas
.
ds
.
scale
=
graphData
.
extra
.
ds
.
scale
;
}
}
catch
(
error
)
{
}
catch
(
error
)
{
let
errorHint
=
[];
let
errorHint
=
[];
// Try extracting filename to see if it was caused by an extension script
// Try extracting filename to see if it was caused by an extension script
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment