Skip to content

Commit

Permalink
Fix resizing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuked88 committed Sep 9, 2024
1 parent 299ad1f commit addb54e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
18 changes: 18 additions & 0 deletions app/js/functions/sb_fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ function toggleSHSB(force = undefined) {

if (force !== undefined) {
if (force) {

setVar("sb_state", "closed");
side_bar.classList.add('closed');
clearIcon.classList.add('closed');
searchCategoryIcon.classList.add('closed');
Expand All @@ -502,6 +504,8 @@ function toggleSHSB(force = undefined) {
sidebar_views.classList.add('full_rounded');

} else {

setVar("sb_state", "open");
side_bar.classList.remove('closed');
clearIcon.classList.remove('closed');
searchCategoryIcon.classList.remove('closed');
Expand All @@ -513,6 +517,9 @@ function toggleSHSB(force = undefined) {
} else {

if (side_bar.classList.contains('closed')) {

setVar("sb_state", "open");

side_bar.classList.remove('closed');
clearIcon.classList.remove('closed');
searchCategoryIcon.classList.remove('closed');
Expand All @@ -526,6 +533,8 @@ function toggleSHSB(force = undefined) {

} else {
if (getVar("sb_minimized") == "false") {

setVar("sb_state", "closed");
side_bar.classList.add('closed');
clearIcon.classList.add('closed');
searchCategoryIcon.classList.add('closed');
Expand All @@ -546,19 +555,28 @@ function toggleSHSB(force = undefined) {
if (getVar("sb_minimized") == "false") {

if (force == undefined) {

setVar("sb_state", "closed");
setVar("sb_minimized", true);
}
main_sidebar.style.width = '45px';
} else {

if (force == undefined) {

setVar("sb_state", "open");
setVar("sb_minimized", false);
main_sidebar.style.width = getVar("sidebarWidth") + 'px' || '300px';
} else if (force == true) {


setVar("sb_state", "closed");

main_sidebar.style.width = '45px';

} else {

setVar("sb_state", "open");
main_sidebar.style.width = getVar("sidebarWidth") + 'px' || '300px';
}

Expand Down
17 changes: 14 additions & 3 deletions app/js/sidebar_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,18 @@ function saveSidebarPosition(sideb) {

function restoreSidebarWidth() {
if (getVar("sidebarWidth") == null) {
setVar("sidebarWidth", 200);
setVar("sidebarWidth", 400);


}
if (getVar("sb_minimized") == null) {
setVar("sb_minimized", "true");
}
if (getVar("sb_current_tab") == null) {
setVar("sb_current_tab", "panel_home");

}

let width_sidebar = "auto";
let cookieValue = getVar("sidebarWidth");
if (cookieValue) {
Expand Down Expand Up @@ -665,7 +675,8 @@ Object.keys(dragHandles).forEach(handleId => {
if (handleId === "sidebar_views") {
if (!event.altKey) return; // Gestisci l'eccezione altKey per sidebar_views
element.style.cursor = 'n-resize'; // Cambia cursore quando alt è premuto
} else if (handleId === "dragHandle" && localStorage.getItem("sb_minimized") === "true") {
} else if (handleId === "dragHandle" && localStorage.getItem("sb_state") === "closed") {

return; // Gestisci l'eccezione minimized
} else {
element.style.cursor = ''; // Cambia cursore per gli altri handle
Expand Down Expand Up @@ -733,7 +744,7 @@ document.addEventListener("mousemove", function (event) {

// Funzioni per gestire gli eventi touch
dragHandle.addEventListener("touchstart", function (event) {
if (localStorage.getItem("sb_minimized")==="false")
if (localStorage.getItem("sb_state") === "open")
{
isDragging = true;
startX = event.touches[0].clientX;
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-n-sidebar"
description = "A simple sidebar for ComfyUI."
version = "1.5.5"
version = "1.5.6"
license = { file = "LICENSE" }

[project.urls]
Expand Down

0 comments on commit addb54e

Please sign in to comment.