mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-23 22:22:11 -03:00
Fix the bug when modal show back to top
This commit is contained in:
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
/* 当模态窗口打开时,禁止body滚动 */
|
/* 当模态窗口打开时,禁止body滚动 */
|
||||||
body.modal-open {
|
body.modal-open {
|
||||||
overflow: hidden;
|
|
||||||
height: 100vh;
|
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-right: var(--scrollbar-width, 0px); /* 补偿滚动条消失导致的页面偏移 */
|
padding-right: var(--scrollbar-width, 0px); /* 补偿滚动条消失导致的页面偏移 */
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export class ModalManager {
|
export class ModalManager {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.modals = new Map();
|
this.modals = new Map();
|
||||||
|
this.scrollPosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
@@ -81,6 +82,9 @@ export class ModalManager {
|
|||||||
modal.onCloseCallback = onCloseCallback;
|
modal.onCloseCallback = onCloseCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store current scroll position before showing modal
|
||||||
|
this.scrollPosition = window.scrollY;
|
||||||
|
|
||||||
if (id === 'deleteModal') {
|
if (id === 'deleteModal') {
|
||||||
modal.element.classList.add('show');
|
modal.element.classList.add('show');
|
||||||
} else {
|
} else {
|
||||||
@@ -88,6 +92,7 @@ export class ModalManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modal.isOpen = true;
|
modal.isOpen = true;
|
||||||
|
document.body.style.top = `-${this.scrollPosition}px`;
|
||||||
document.body.classList.add('modal-open');
|
document.body.classList.add('modal-open');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +103,11 @@ export class ModalManager {
|
|||||||
modal.onClose();
|
modal.onClose();
|
||||||
modal.isOpen = false;
|
modal.isOpen = false;
|
||||||
|
|
||||||
|
// Remove fixed positioning and restore scroll position
|
||||||
|
document.body.classList.remove('modal-open');
|
||||||
|
document.body.style.top = '';
|
||||||
|
window.scrollTo(0, this.scrollPosition);
|
||||||
|
|
||||||
// Execute onClose callback if exists
|
// Execute onClose callback if exists
|
||||||
if (modal.onCloseCallback) {
|
if (modal.onCloseCallback) {
|
||||||
modal.onCloseCallback();
|
modal.onCloseCallback();
|
||||||
|
|||||||
Reference in New Issue
Block a user