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
04234152
Commit
04234152
authored
Apr 02, 2023
by
pythongosssss
Browse files
Add support for multiselect
parent
26dc8e30
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
web/extensions/core/snapToGrid.js
web/extensions/core/snapToGrid.js
+14
-11
No files found.
web/extensions/core/snapToGrid.js
View file @
04234152
...
...
@@ -28,7 +28,10 @@ app.registerExtension({
const
r
=
onNodeMoved
?.
apply
(
this
,
arguments
);
if
(
app
.
shiftDown
)
{
node
.
alignToGrid
();
// Ensure all selected nodes are realigned
for
(
const
id
in
this
.
selected_nodes
)
{
this
.
selected_nodes
[
id
].
alignToGrid
();
}
}
return
r
;
...
...
@@ -39,7 +42,7 @@ app.registerExtension({
app
.
graph
.
onNodeAdded
=
function
(
node
)
{
const
onResize
=
node
.
onResize
;
node
.
onResize
=
function
()
{
if
(
app
.
shiftDown
)
{
if
(
app
.
shiftDown
)
{
const
w
=
LiteGraph
.
CANVAS_GRID_SIZE
*
Math
.
round
(
node
.
size
[
0
]
/
LiteGraph
.
CANVAS_GRID_SIZE
);
const
h
=
LiteGraph
.
CANVAS_GRID_SIZE
*
Math
.
round
(
node
.
size
[
1
]
/
LiteGraph
.
CANVAS_GRID_SIZE
);
node
.
size
[
0
]
=
w
;
...
...
@@ -50,10 +53,10 @@ app.registerExtension({
return
onNodeAdded
?.
apply
(
this
,
arguments
);
};
// Draw a preview of where the node will go if holding shift
// Draw a preview of where the node will go if holding shift
and the node is selected
const
origDrawNode
=
LGraphCanvas
.
prototype
.
drawNode
;
LGraphCanvas
.
prototype
.
drawNode
=
function
(
node
,
ctx
)
{
if
(
app
.
shiftDown
&&
node
===
this
.
node_dragged
)
{
if
(
app
.
shiftDown
&&
this
.
node_dragged
&&
node
.
id
in
this
.
selected_nodes
)
{
const
x
=
LiteGraph
.
CANVAS_GRID_SIZE
*
Math
.
round
(
node
.
pos
[
0
]
/
LiteGraph
.
CANVAS_GRID_SIZE
);
const
y
=
LiteGraph
.
CANVAS_GRID_SIZE
*
Math
.
round
(
node
.
pos
[
1
]
/
LiteGraph
.
CANVAS_GRID_SIZE
);
...
...
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