From ab4f00610735790fba1a34aa8e1634af8bdaea43 Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 23 Jun 2026 15:41:22 +0800 Subject: [PATCH] fix(lightbox): bind interactions immediately, before image loads bindInteractions() was only called from start(), which waits for the image load event. during the load window Esc/scroll/backdrop-click did nothing. bind right after appending the overlay so the lightbox is closable throughout the load. --- public/js/lightbox.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/js/lightbox.js b/public/js/lightbox.js index 1b4edc4..9eeb04d 100644 --- a/public/js/lightbox.js +++ b/public/js/lightbox.js @@ -179,6 +179,8 @@ // 焦点移入灯箱 overlay.focus(); + // 立即绑定交互(不等图片加载):加载期间 Esc/滚动/点背景也须可关闭。 + bindInteractions(); // 图片加载后再做动画(naturalW/H 要等加载) var start = function () { @@ -203,7 +205,6 @@ overlay.style.opacity = "1"; img.style.opacity = "1"; }); - bindInteractions(); return; } @@ -226,8 +227,6 @@ img.style.opacity = "1"; overlay.style.opacity = "1"; }); - - bindInteractions(); }; if (img.complete && img.naturalWidth) {