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
d68350ee
Commit
d68350ee
authored
Mar 26, 2023
by
comfyanonymous
Browse files
Merge branch 'draggable-menu' of
https://github.com/jn-jairo/ComfyUI
parents
754553fa
48d4edbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
web/scripts/ui.js
web/scripts/ui.js
+51
-0
web/style.css
web/style.css
+25
-0
No files found.
web/scripts/ui.js
View file @
d68350ee
...
@@ -35,6 +35,54 @@ function $el(tag, propsOrChildren, children) {
...
@@ -35,6 +35,54 @@ function $el(tag, propsOrChildren, children) {
return
element
;
return
element
;
}
}
function
dragElement
(
dragEl
)
{
var
posDiffX
=
0
,
posDiffY
=
0
,
posStartX
=
0
,
posStartY
=
0
,
newPosX
=
0
,
newPosY
=
0
;
if
(
dragEl
.
getElementsByClassName
(
'
drag-handle
'
)[
0
])
{
// if present, the handle is where you move the DIV from:
dragEl
.
getElementsByClassName
(
'
drag-handle
'
)[
0
].
onmousedown
=
dragMouseDown
;
}
else
{
// otherwise, move the DIV from anywhere inside the DIV:
dragEl
.
onmousedown
=
dragMouseDown
;
}
function
dragMouseDown
(
e
)
{
e
=
e
||
window
.
event
;
e
.
preventDefault
();
// get the mouse cursor position at startup:
posStartX
=
e
.
clientX
;
posStartY
=
e
.
clientY
;
document
.
onmouseup
=
closeDragElement
;
// call a function whenever the cursor moves:
document
.
onmousemove
=
elementDrag
;
}
function
elementDrag
(
e
)
{
e
=
e
||
window
.
event
;
e
.
preventDefault
();
// calculate the new cursor position:
posDiffX
=
e
.
clientX
-
posStartX
;
posDiffY
=
e
.
clientY
-
posStartY
;
posStartX
=
e
.
clientX
;
posStartY
=
e
.
clientY
;
newPosX
=
Math
.
min
((
document
.
body
.
clientWidth
-
dragEl
.
clientWidth
),
Math
.
max
(
0
,
(
dragEl
.
offsetLeft
+
posDiffX
)));
newPosY
=
Math
.
min
((
document
.
body
.
clientHeight
-
dragEl
.
clientHeight
),
Math
.
max
(
0
,
(
dragEl
.
offsetTop
+
posDiffY
)));
// set the element's new position:
dragEl
.
style
.
top
=
newPosY
+
"
px
"
;
dragEl
.
style
.
left
=
newPosX
+
"
px
"
;
}
function
closeDragElement
()
{
// stop moving when mouse button is released:
document
.
onmouseup
=
null
;
document
.
onmousemove
=
null
;
}
}
class
ComfyDialog
{
class
ComfyDialog
{
constructor
()
{
constructor
()
{
this
.
element
=
$el
(
"
div.comfy-modal
"
,
{
parent
:
document
.
body
},
[
this
.
element
=
$el
(
"
div.comfy-modal
"
,
{
parent
:
document
.
body
},
[
...
@@ -253,6 +301,7 @@ export class ComfyUI {
...
@@ -253,6 +301,7 @@ export class ComfyUI {
this
.
menuContainer
=
$el
(
"
div.comfy-menu
"
,
{
parent
:
document
.
body
},
[
this
.
menuContainer
=
$el
(
"
div.comfy-menu
"
,
{
parent
:
document
.
body
},
[
$el
(
"
div
"
,
{
style
:
{
overflow
:
"
hidden
"
,
position
:
"
relative
"
,
width
:
"
100%
"
}
},
[
$el
(
"
div
"
,
{
style
:
{
overflow
:
"
hidden
"
,
position
:
"
relative
"
,
width
:
"
100%
"
}
},
[
$el
(
"
span.drag-handle
"
),
$el
(
"
span
"
,
{
$
:
(
q
)
=>
(
this
.
queueSize
=
q
)
}),
$el
(
"
span
"
,
{
$
:
(
q
)
=>
(
this
.
queueSize
=
q
)
}),
$el
(
"
button.comfy-settings-btn
"
,
{
textContent
:
"
⚙️
"
,
onclick
:
()
=>
this
.
settings
.
show
()
}),
$el
(
"
button.comfy-settings-btn
"
,
{
textContent
:
"
⚙️
"
,
onclick
:
()
=>
this
.
settings
.
show
()
}),
]),
]),
...
@@ -331,6 +380,8 @@ export class ComfyUI {
...
@@ -331,6 +380,8 @@ export class ComfyUI {
$el
(
"
button
"
,
{
textContent
:
"
Load Default
"
,
onclick
:
()
=>
app
.
loadGraphData
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Load Default
"
,
onclick
:
()
=>
app
.
loadGraphData
()
}),
]);
]);
dragElement
(
this
.
menuContainer
);
this
.
setStatus
({
exec_info
:
{
queue_remaining
:
"
X
"
}
});
this
.
setStatus
({
exec_info
:
{
queue_remaining
:
"
X
"
}
});
}
}
...
...
web/style.css
View file @
d68350ee
...
@@ -111,6 +111,31 @@ body {
...
@@ -111,6 +111,31 @@ body {
width
:
50%
;
width
:
50%
;
}
}
.comfy-menu
span
.drag-handle
{
width
:
10px
;
height
:
20px
;
display
:
inline-block
;
overflow
:
hidden
;
line-height
:
5px
;
padding
:
3px
4px
;
cursor
:
move
;
vertical-align
:
middle
;
margin-top
:
-.4em
;
margin-left
:
-.2em
;
font-size
:
12px
;
font-family
:
sans-serif
;
letter-spacing
:
2px
;
color
:
#cccccc
;
text-shadow
:
1px
0
1px
black
;
position
:
absolute
;
top
:
0
;
left
:
0
;
}
.comfy-menu
span
.drag-handle
::after
{
content
:
'.. .. ..'
;
}
.comfy-queue-btn
{
.comfy-queue-btn
{
width
:
100%
;
width
:
100%
;
}
}
...
...
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