lobehub / sd-webui-lobe-theme

🅰️ Lobe theme - The modern theme for stable diffusion webui, exquisite interface design, highly customizable UI, and efficiency boosting features.
https://github.com/AUTOMATIC1111/stable-diffusion-webui
GNU Affero General Public License v3.0
2.39k stars 222 forks source link

[Bug] 瀏覽圖片的 前後按鈕 跟 鍵盤控制 無效 #319

Closed bluelovers closed 11 months ago

bluelovers commented 1 year ago

💻 系统环境 | Operating System

Windows

🌐 浏览器 | Browser

Chrome

🐛 问题描述 | Bug Description

image

瀏覽圖片的 前後按鈕 跟 鍵盤控制 無效 無法正常切換圖片

🚦 期望结果 | Expected Behavior

No response

📷 复现步骤 | Recurrence Steps

No response

📝 补充信息 | Additional Information

No response

bluelovers commented 1 year ago
function _all_gallery_buttons() {
    var _list = gradioApp().querySelectorAll('[style="display: block;"].tabitem, [style="display: flex;"] > div[id$=_results]');
    var allGalleryButtons;
    for (const elem of _list) {
        const ret = elem.querySelectorAll('div[id$=_gallery].gradio-gallery .thumbnails > .thumbnail-item.thumbnail-small')
        if (ret?.length) {
            allGalleryButtons = ret;
            break;
        }
    }

    var visibleGalleryButtons = [];
    allGalleryButtons?.forEach(function (elem) {
        if (elem.parentElement.offsetParent)
        {
            visibleGalleryButtons.push(elem);
        }
    });
    return visibleGalleryButtons;
}

function _selected_gallery_button() {
    return _all_gallery_buttons().filter(elem => elem.classList.contains('selected')).pop();
}

function modalImageSwitch(offset) {
    var galleryButtons = _all_gallery_buttons();

    if (galleryButtons.length > 1) {
        var currentButton = _selected_gallery_button();

        var result = -1;
        galleryButtons.forEach(function(v, i) {
            if (v == currentButton) {
                result = i;
            }
        });

        if (result != -1) {
            var nextButton = galleryButtons[negmod((result + offset), galleryButtons.length)];
            nextButton.click();
            const modalImage = gradioApp().getElementById("modalImage");
            const modal = gradioApp().getElementById("lightboxModal");
            modalImage.src = nextButton.children[0].src;
            if (modalImage.style.display === 'none') {
                modal.style.setProperty('background-image', `url(${modalImage.src})`);
            }
            setTimeout(function() {
                modal.focus();
            }, 10);
        }
    }
}
github-actions[bot] commented 11 months ago

Since the issue was labeled with Inactive, and no response in 30 days. This issue will be closed. If you have any questions, you can comment and reply.

由于该 issue 被标记为 Inactive,同时 30 天未收到回应。现关闭 issue,若有任何问题,可评论回复。