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