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
8a92ac21
Commit
8a92ac21
authored
Jan 22, 2024
by
pythongosssss
Browse files
Ability to hide menu
Responsive setting screen Touch events for zooming/context menu
parent
f2d432f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
252 additions
and
62 deletions
+252
-62
web/extensions/core/simpleTouchSupport.js
web/extensions/core/simpleTouchSupport.js
+102
-0
web/scripts/ui.js
web/scripts/ui.js
+29
-5
web/scripts/ui/settings.js
web/scripts/ui/settings.js
+11
-1
web/style.css
web/style.css
+110
-56
No files found.
web/extensions/core/simpleTouchSupport.js
0 → 100644
View file @
8a92ac21
import
{
app
}
from
"
../../scripts/app.js
"
;
let
touchZooming
;
let
touchCount
=
0
;
app
.
registerExtension
({
name
:
"
Comfy.SimpleTouchSupport
"
,
setup
()
{
let
zoomPos
;
let
touchTime
;
let
lastTouch
;
function
getMultiTouchPos
(
e
)
{
return
Math
.
hypot
(
e
.
touches
[
0
].
clientX
-
e
.
touches
[
1
].
clientX
,
e
.
touches
[
0
].
clientY
-
e
.
touches
[
1
].
clientY
);
}
app
.
canvasEl
.
addEventListener
(
"
touchstart
"
,
(
e
)
=>
{
touchCount
++
;
lastTouch
=
null
;
if
(
e
.
touches
?.
length
===
1
)
{
// Store start time for press+hold for context menu
touchTime
=
new
Date
();
lastTouch
=
e
.
touches
[
0
];
}
else
{
touchTime
=
null
;
if
(
e
.
touches
?.
length
===
2
)
{
// Store center pos for zoom
zoomPos
=
getMultiTouchPos
(
e
);
app
.
canvas
.
pointer_is_down
=
false
;
}
}
},
true
);
app
.
canvasEl
.
addEventListener
(
"
touchend
"
,
(
e
)
=>
{
touchZooming
=
false
;
touchCount
=
e
.
touches
?.
length
??
touchCount
-
1
;
if
(
touchTime
&&
!
e
.
touches
?.
length
)
{
if
(
new
Date
()
-
touchTime
>
600
)
{
try
{
// hack to get litegraph to use this event
e
.
constructor
=
CustomEvent
;
}
catch
(
error
)
{}
e
.
clientX
=
lastTouch
.
clientX
;
e
.
clientY
=
lastTouch
.
clientY
;
app
.
canvas
.
pointer_is_down
=
true
;
app
.
canvas
.
_mousedown_callback
(
e
);
}
touchTime
=
null
;
}
});
app
.
canvasEl
.
addEventListener
(
"
touchmove
"
,
(
e
)
=>
{
touchTime
=
null
;
if
(
e
.
touches
?.
length
===
2
)
{
app
.
canvas
.
pointer_is_down
=
false
;
touchZooming
=
true
;
LiteGraph
.
closeAllContextMenus
();
app
.
canvas
.
search_box
?.
close
();
const
newZoomPos
=
getMultiTouchPos
(
e
);
const
midX
=
(
e
.
touches
[
0
].
clientX
+
e
.
touches
[
1
].
clientX
)
/
2
;
const
midY
=
(
e
.
touches
[
0
].
clientY
+
e
.
touches
[
1
].
clientY
)
/
2
;
let
scale
=
app
.
canvas
.
ds
.
scale
;
const
diff
=
zoomPos
-
newZoomPos
;
if
(
diff
>
0.5
)
{
scale
*=
1
/
1.07
;
}
else
if
(
diff
<
-
0.5
)
{
scale
*=
1.07
;
}
app
.
canvas
.
ds
.
changeScale
(
scale
,
[
midX
,
midY
]);
app
.
canvas
.
setDirty
(
true
,
true
);
zoomPos
=
newZoomPos
;
}
},
true
);
},
});
const
processMouseDown
=
LGraphCanvas
.
prototype
.
processMouseDown
;
LGraphCanvas
.
prototype
.
processMouseDown
=
function
(
e
)
{
if
(
touchZooming
||
touchCount
)
{
return
;
}
return
processMouseDown
.
apply
(
this
,
arguments
);
};
const
processMouseMove
=
LGraphCanvas
.
prototype
.
processMouseMove
;
LGraphCanvas
.
prototype
.
processMouseMove
=
function
(
e
)
{
if
(
touchZooming
||
touchCount
>
1
)
{
return
;
}
return
processMouseMove
.
apply
(
this
,
arguments
);
};
web/scripts/ui.js
View file @
8a92ac21
...
@@ -394,18 +394,42 @@ export class ComfyUI {
...
@@ -394,18 +394,42 @@ export class ComfyUI {
}
}
});
});
this
.
menuContainer
=
$el
(
"
div.comfy-menu
"
,
{
parent
:
document
.
body
},
[
this
.
menuHamburger
=
$el
(
$el
(
"
div.drag-handle
"
,
{
"
div.comfy-menu-hamburger
"
,
{
parent
:
document
.
body
,
onclick
:
()
=>
{
this
.
menuContainer
.
style
.
display
=
"
block
"
;
this
.
menuHamburger
.
style
.
display
=
"
none
"
;
},
},
[
$el
(
"
div
"
),
$el
(
"
div
"
),
$el
(
"
div
"
)]
);
this
.
menuContainer
=
$el
(
"
div.comfy-menu
"
,
{
parent
:
document
.
body
},
[
$el
(
"
div.drag-handle.comfy-menu-header
"
,
{
style
:
{
style
:
{
overflow
:
"
hidden
"
,
overflow
:
"
hidden
"
,
position
:
"
relative
"
,
position
:
"
relative
"
,
width
:
"
100%
"
,
width
:
"
100%
"
,
cursor
:
"
default
"
cursor
:
"
default
"
}
}
},
[
},
[
$el
(
"
span.drag-handle
"
),
$el
(
"
span.drag-handle
"
),
$el
(
"
span
"
,
{
$
:
(
q
)
=>
(
this
.
queueSize
=
q
)}),
$el
(
"
span.comfy-menu-queue-size
"
,
{
$
:
(
q
)
=>
(
this
.
queueSize
=
q
)
}),
$el
(
"
button.comfy-settings-btn
"
,
{
textContent
:
"
⚙️
"
,
onclick
:
()
=>
this
.
settings
.
show
()}),
$el
(
"
div.comfy-menu-actions
"
,
[
$el
(
"
button.comfy-settings-btn
"
,
{
textContent
:
"
⚙️
"
,
onclick
:
()
=>
this
.
settings
.
show
(),
}),
$el
(
"
button.comfy-close-menu-btn
"
,
{
textContent
:
"
\
u00d7
"
,
onclick
:
()
=>
{
this
.
menuContainer
.
style
.
display
=
"
none
"
;
this
.
menuHamburger
.
style
.
display
=
"
flex
"
;
},
}),
]),
]),
]),
$el
(
"
button.comfy-queue-btn
"
,
{
$el
(
"
button.comfy-queue-btn
"
,
{
id
:
"
queue-button
"
,
id
:
"
queue-button
"
,
...
...
web/scripts/ui/settings.js
View file @
8a92ac21
...
@@ -16,7 +16,17 @@ export class ComfySettingsDialog extends ComfyDialog {
...
@@ -16,7 +16,17 @@ export class ComfySettingsDialog extends ComfyDialog {
},
},
[
[
$el
(
"
table.comfy-modal-content.comfy-table
"
,
[
$el
(
"
table.comfy-modal-content.comfy-table
"
,
[
$el
(
"
caption
"
,
{
textContent
:
"
Settings
"
}),
$el
(
"
caption
"
,
{
textContent
:
"
Settings
"
},
$el
(
"
button.comfy-btn
"
,
{
type
:
"
button
"
,
textContent
:
"
\
u00d7
"
,
onclick
:
()
=>
{
this
.
element
.
close
();
},
})
),
$el
(
"
tbody
"
,
{
$
:
(
tbody
)
=>
(
this
.
textElement
=
tbody
)
}),
$el
(
"
tbody
"
,
{
$
:
(
tbody
)
=>
(
this
.
textElement
=
tbody
)
}),
$el
(
"
button
"
,
{
$el
(
"
button
"
,
{
type
:
"
button
"
,
type
:
"
button
"
,
...
...
web/style.css
View file @
8a92ac21
...
@@ -82,6 +82,24 @@ body {
...
@@ -82,6 +82,24 @@ body {
margin
:
3px
3px
3px
4px
;
margin
:
3px
3px
3px
4px
;
}
}
.comfy-menu-hamburger
{
position
:
fixed
;
top
:
10px
;
z-index
:
9999
;
right
:
10px
;
width
:
30px
;
display
:
none
;
gap
:
8px
;
flex-direction
:
column
;
cursor
:
pointer
;
}
.comfy-menu-hamburger
div
{
height
:
3px
;
width
:
100%
;
border-radius
:
20px
;
background-color
:
white
;
}
.comfy-menu
{
.comfy-menu
{
font-size
:
15px
;
font-size
:
15px
;
position
:
absolute
;
position
:
absolute
;
...
@@ -101,6 +119,44 @@ body {
...
@@ -101,6 +119,44 @@ body {
box-shadow
:
3px
3px
8px
rgba
(
0
,
0
,
0
,
0.4
);
box-shadow
:
3px
3px
8px
rgba
(
0
,
0
,
0
,
0.4
);
}
}
.comfy-menu-header
{
display
:
flex
;
}
.comfy-menu-actions
{
display
:
flex
;
gap
:
3px
;
align-items
:
center
;
height
:
20px
;
position
:
relative
;
top
:
-1px
;
font-size
:
22px
;
}
.comfy-menu
.comfy-menu-actions
button
{
background-color
:
rgba
(
0
,
0
,
0
,
0
);
padding
:
0
;
border
:
none
;
cursor
:
pointer
;
font-size
:
inherit
;
}
.comfy-menu
.comfy-menu-actions
.comfy-settings-btn
{
font-size
:
0.6em
;
}
button
.comfy-close-menu-btn
{
font-size
:
1em
;
line-height
:
12px
;
color
:
#ccc
;
position
:
relative
;
top
:
-1px
;
}
.comfy-menu-queue-size
{
flex
:
auto
;
}
.comfy-menu
button
,
.comfy-menu
button
,
.comfy-modal
button
{
.comfy-modal
button
{
font-size
:
20px
;
font-size
:
20px
;
...
@@ -121,7 +177,6 @@ body {
...
@@ -121,7 +177,6 @@ body {
width
:
100%
;
width
:
100%
;
}
}
.comfy-toggle-switch
,
.comfy-btn
,
.comfy-btn
,
.comfy-menu
>
button
,
.comfy-menu
>
button
,
.comfy-menu-btns
button
,
.comfy-menu-btns
button
,
...
@@ -140,17 +195,11 @@ body {
...
@@ -140,17 +195,11 @@ body {
.comfy-menu-btns
button
:hover
,
.comfy-menu-btns
button
:hover
,
.comfy-menu
.comfy-list
button
:hover
,
.comfy-menu
.comfy-list
button
:hover
,
.comfy-modal
button
:hover
,
.comfy-modal
button
:hover
,
.comfy-
settings-bt
n
:hover
{
.comfy-
menu-actions
butto
n
:hover
{
filter
:
brightness
(
1.2
);
filter
:
brightness
(
1.2
);
cursor
:
pointer
;
cursor
:
pointer
;
}
}
.comfy-menu
span
.drag-handle
{
position
:
absolute
;
top
:
0
;
left
:
0
;
}
span
.drag-handle
{
span
.drag-handle
{
width
:
10px
;
width
:
10px
;
height
:
20px
;
height
:
20px
;
...
@@ -215,15 +264,6 @@ span.drag-handle::after {
...
@@ -215,15 +264,6 @@ span.drag-handle::after {
font-size
:
12px
;
font-size
:
12px
;
}
}
button
.comfy-settings-btn
{
background-color
:
rgba
(
0
,
0
,
0
,
0
);
font-size
:
12px
;
padding
:
0
;
position
:
absolute
;
right
:
0
;
border
:
none
;
}
button
.comfy-queue-btn
{
button
.comfy-queue-btn
{
margin
:
6px
0
!important
;
margin
:
6px
0
!important
;
}
}
...
@@ -269,7 +309,19 @@ button.comfy-queue-btn {
...
@@ -269,7 +309,19 @@ button.comfy-queue-btn {
}
}
.comfy-menu
span
.drag-handle
{
.comfy-menu
span
.drag-handle
{
visibility
:
hidden
display
:
none
;
}
.comfy-menu-queue-size
{
flex
:
unset
;
}
.comfy-menu-header
{
justify-content
:
space-between
;
}
.comfy-menu-actions
{
gap
:
10px
;
font-size
:
28px
;
}
}
}
}
...
@@ -320,7 +372,7 @@ dialog::backdrop {
...
@@ -320,7 +372,7 @@ dialog::backdrop {
text-align
:
right
;
text-align
:
right
;
}
}
#comfy-settings-dialog
button
{
#comfy-settings-dialog
tbody
button
,
#comfy-settings-dialog
table
>
button
{
background-color
:
var
(
--bg-color
);
background-color
:
var
(
--bg-color
);
border
:
1px
var
(
--border-color
)
solid
;
border
:
1px
var
(
--border-color
)
solid
;
border-radius
:
0
;
border-radius
:
0
;
...
@@ -343,12 +395,33 @@ dialog::backdrop {
...
@@ -343,12 +395,33 @@ dialog::backdrop {
}
}
.comfy-table
caption
{
.comfy-table
caption
{
position
:
sticky
;
top
:
0
;
background-color
:
var
(
--bg-color
);
background-color
:
var
(
--bg-color
);
color
:
var
(
--input-text
);
color
:
var
(
--input-text
);
font-size
:
1rem
;
font-size
:
1rem
;
font-weight
:
bold
;
font-weight
:
bold
;
padding
:
8px
;
padding
:
8px
;
text-align
:
center
;
text-align
:
center
;
border-bottom
:
1px
solid
var
(
--border-color
);
}
.comfy-table
caption
.comfy-btn
{
position
:
absolute
;
top
:
-2px
;
right
:
0
;
bottom
:
0
;
cursor
:
pointer
;
border
:
none
;
height
:
100%
;
border-radius
:
0
;
aspect-ratio
:
1
/
1
;
user-select
:
none
;
font-size
:
20px
;
}
.comfy-table
caption
.comfy-btn
:focus
{
outline
:
none
;
}
}
.comfy-table
tr
:nth-child
(
even
)
{
.comfy-table
tr
:nth-child
(
even
)
{
...
@@ -435,43 +508,6 @@ dialog::backdrop {
...
@@ -435,43 +508,6 @@ dialog::backdrop {
margin-left
:
5px
;
margin-left
:
5px
;
}
}
.comfy-toggle-switch
{
border-width
:
2px
;
display
:
flex
;
background-color
:
var
(
--comfy-input-bg
);
margin
:
2px
0
;
white-space
:
nowrap
;
}
.comfy-toggle-switch
label
{
padding
:
2px
0px
3px
6px
;
flex
:
auto
;
border-radius
:
8px
;
align-items
:
center
;
display
:
flex
;
justify-content
:
center
;
}
.comfy-toggle-switch
label
:first-child
{
border-top-left-radius
:
8px
;
border-bottom-left-radius
:
8px
;
}
.comfy-toggle-switch
label
:last-child
{
border-top-right-radius
:
8px
;
border-bottom-right-radius
:
8px
;
}
.comfy-toggle-switch
.comfy-toggle-selected
{
background-color
:
var
(
--comfy-menu-bg
);
}
#extraOptions
{
padding
:
4px
;
background-color
:
var
(
--bg-color
);
margin-bottom
:
4px
;
border-radius
:
4px
;
}
/* Search box */
/* Search box */
.litegraph.litesearchbox
{
.litegraph.litesearchbox
{
...
@@ -498,3 +534,21 @@ dialog::backdrop {
...
@@ -498,3 +534,21 @@ dialog::backdrop {
color
:
var
(
--input-text
);
color
:
var
(
--input-text
);
filter
:
brightness
(
50%
);
filter
:
brightness
(
50%
);
}
}
@media
only
screen
and
(
max-width
:
450px
)
{
#comfy-settings-dialog
.comfy-table
tbody
{
display
:
grid
;
}
#comfy-settings-dialog
.comfy-table
tr
{
display
:
grid
;
}
#comfy-settings-dialog
tr
>
td
:first-child
{
text-align
:
center
;
border-bottom
:
none
;
padding-bottom
:
0
;
}
#comfy-settings-dialog
tr
>
td
:not
(
:first-child
)
{
text-align
:
center
;
border-top
:
none
;
}
}
\ No newline at end of file
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