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
c93dc2fb
Commit
c93dc2fb
authored
Mar 30, 2023
by
pythongosssss
Browse files
Remove bottom anchor
parent
6481c903
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
18 deletions
+12
-18
web/scripts/ui.js
web/scripts/ui.js
+12
-18
No files found.
web/scripts/ui.js
View file @
c93dc2fb
...
...
@@ -50,19 +50,24 @@ function dragElement(dragEl, settings) {
dragEl
.
onmousedown
=
dragMouseDown
;
}
// When the element resizes (e.g. view queue) ensure it is still in the windows bounds
const
resizeObserver
=
new
ResizeObserver
(()
=>
{
ensureInBounds
();
}).
observe
(
dragEl
);
function
ensureInBounds
()
{
if
(
dragEl
.
classList
.
contains
(
"
comfy-menu-manual-pos
"
))
{
newPosX
=
Math
.
min
(
document
.
body
.
clientWidth
-
dragEl
.
clientWidth
,
Math
.
max
(
0
,
dragEl
.
offsetLeft
));
newPosY
=
Math
.
min
(
document
.
body
.
clientHeight
-
dragEl
.
clientHeight
,
Math
.
max
(
0
,
dragEl
.
offsetTop
));
positionElement
();
}
}
function
positionElement
()
{
const
halfWidth
=
document
.
body
.
clientWidth
/
2
;
const
halfHeight
=
document
.
body
.
clientHeight
/
2
;
const
anchorRight
=
newPosX
+
dragEl
.
clientWidth
/
2
>
halfWidth
;
const
anchorBottom
=
newPosY
+
dragEl
.
clientHeight
/
2
>
halfHeight
;
// set the element's new position:
if
(
anchorRight
)
{
...
...
@@ -72,22 +77,15 @@ function dragElement(dragEl, settings) {
dragEl
.
style
.
left
=
newPosX
+
"
px
"
;
dragEl
.
style
.
right
=
"
unset
"
;
}
if
(
anchorBottom
)
{
dragEl
.
style
.
top
=
"
unset
"
;
dragEl
.
style
.
bottom
=
document
.
body
.
clientHeight
-
newPosY
-
dragEl
.
clientHeight
+
"
px
"
;
}
else
{
dragEl
.
style
.
top
=
newPosY
+
"
px
"
;
dragEl
.
style
.
bottom
=
"
unset
"
;
}
if
(
savePos
)
{
localStorage
.
setItem
(
"
Comfy.MenuPosition
"
,
JSON
.
stringify
({
left
:
dragEl
.
style
.
left
,
right
:
dragEl
.
style
.
right
,
top
:
dragEl
.
style
.
top
,
bottom
:
dragEl
.
style
.
bottom
,
x
:
dragEl
.
offsetLeft
,
y
:
dragEl
.
offsetTop
,
})
);
}
...
...
@@ -97,11 +95,9 @@ function dragElement(dragEl, settings) {
let
pos
=
localStorage
.
getItem
(
"
Comfy.MenuPosition
"
);
if
(
pos
)
{
pos
=
JSON
.
parse
(
pos
);
dragEl
.
style
.
left
=
pos
.
left
;
dragEl
.
style
.
right
=
pos
.
right
;
dragEl
.
style
.
top
=
pos
.
top
;
dragEl
.
style
.
bottom
=
pos
.
bottom
;
dragEl
.
classList
.
add
(
"
comfy-menu-manual-pos
"
);
newPosX
=
pos
.
x
;
newPosY
=
pos
.
y
;
positionElement
();
ensureInBounds
();
}
}
...
...
@@ -150,9 +146,7 @@ function dragElement(dragEl, settings) {
}
window
.
addEventListener
(
"
resize
"
,
()
=>
{
if
(
dragEl
.
classList
.
contains
(
"
comfy-menu-manual-pos
"
))
{
ensureInBounds
();
}
});
function
closeDragElement
()
{
...
...
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