diff --git a/plugins/gallery/main.js b/plugins/gallery/main.js index 3a6ddf4..3832eea 100644 --- a/plugins/gallery/main.js +++ b/plugins/gallery/main.js @@ -340,7 +340,6 @@ } function renderGrid () { - if (io) { try { io.disconnect() } catch (e) { /* ignore */ } } clear(grid) var gap = 6 // 每次重排都重新量一次宽度:面板显隐/停靠栏展开时 gridW 可能是旧值, @@ -380,22 +379,6 @@ } // ── v1.8.0:懒加载观察器 / 滚动位置保持 / 选中态就地更新 ───────────────── - var io = null - function ensureIO () { - if (io || typeof global.IntersectionObserver !== 'function') return io - io = new global.IntersectionObserver(function (list) { - for (var i = 0; i < list.length; i++) { - var e = list[i] - if (!e || !e.isIntersecting) continue - var node = e.target - try { io.unobserve(node) } catch (err) { /* ignore */ } - var fn = node && node.__iwbBoot - node.__iwbBoot = null - if (typeof fn === 'function') fn() - } - }, { root: null, rootMargin: '300px 0px' }) - return io - } // 找到真正滚动的祖先(grid 自己在 .iwb-history 里滚),用于重排后恢复位置 function scrollerOf () { var p = grid && grid.parentNode @@ -467,7 +450,6 @@ fail('缩略图加载失败(点击重试)') }) img.addEventListener('click', function (e) { pick(it.name, !!(e && e.shiftKey)) }) - img.addEventListener('dblclick', function () { ctx.gallery.preview(it.name) }) img.addEventListener('dragstart', function (e) { try { var names = (picked[it.name] && count() > 1) ? pickedNames() : [it.name] @@ -498,11 +480,8 @@ } // v1.8.0:缩略图按可见性懒加载(IntersectionObserver,上下预取 300px)—— // 原来一次性对全部条目发 IPC 取缩略图,列表一长首屏就慢。 - box.__iwbBoot = boot - var io0 = ensureIO() - // 前 30 张仍然同步取(首屏 / e2e 需要立刻可见),其余按可见性懒加载 - if (!io0 || Number(seq) < 30) boot() - else io0.observe(box) + // v1.8.1:撤销懒加载——IntersectionObserver 在停靠栏里不稳定,大量卡片停在「加载中…」 + boot() box.addEventListener('contextmenu', function (e) { openMenu(e, it) }) var acts = el('div', { class: 'iwb-history-actions' }) function act (label, title, fn) { @@ -546,12 +525,27 @@ }).catch(function () { setStatus('下载失败,可再点一次重试') }) } + // v1.8.1:双击打开改成在 grid 上做事件委托 —— 原来监听在 上,一旦卡片被重绘替换, + // dblclick 就永远落不到同一个元素(用户反馈「双击打不开」)。委托到容器后按 data-name 处理。 + grid.addEventListener('dblclick', function (e) { + var node = e.target + while (node && node !== grid && !(node.getAttribute && node.getAttribute('data-name'))) node = node.parentNode + if (!node || node === grid) return + var nm = node.getAttribute('data-name') + if (!nm) return + e.preventDefault() + e.stopPropagation() + try { ctx.gallery.preview(nm) } catch (err) { /* ignore */ } + }) + function pick (name, shift) { if (shift) { if (picked[name]) delete picked[name]; else picked[name] = 1 } else { picked = {}; picked[name] = 1 } // v1.8.0:选中只就地改 class/勾选角标 —— 原来整个网格重建,滚动条被顶回顶部, // 而且正在双击的那张 被换掉,双击因此经常打不开。 syncSelection() renderHead() + // 顺手量一次宽度:面板被拖窄后如果没有其它触发条件,列数会停在旧值上(卡片被窗口裁掉) + try { measure() } catch (e) { /* ignore */ } } function syncSelection () { var managed = !!count() diff --git a/plugins/gallery/manifest.json b/plugins/gallery/manifest.json index 90a2367..f68deb4 100644 --- a/plugins/gallery/manifest.json +++ b/plugins/gallery/manifest.json @@ -1,7 +1,7 @@ { "id": "gallery", "name": "图库", - "version": "1.8.0", + "version": "1.8.1", "apiVersion": 1, "main": "main.js", "style": "styles.css", @@ -13,7 +13,7 @@ "图库" ], "files": { - "main.js": "39a93d36a9294c183136e20f90c8c8885a67ada6adc1602b334836cfcba0e15d", + "main.js": "6dd3bf43dce74236d4904c4e33639772ef03bd4cd80d6e5a4532ff7ca7ed085a", "styles.css": "14d374b5d0e1461cb1ca2b125865e9c27df7c3bd79c11caa0afc52152c7d0aef" } } diff --git a/plugins/index.json b/plugins/index.json index edb3fd8..156ded9 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -33,10 +33,10 @@ "dir": "gallery", "main": "main.js", "style": "styles.css", - "version": "1.8.0", + "version": "1.8.1", "files": { - "manifest.json": "3eabd6d707e2154a955049bda895d9c4f32afecaa00df1d9b3e92c92fd4930cd", - "main.js": "39a93d36a9294c183136e20f90c8c8885a67ada6adc1602b334836cfcba0e15d", + "manifest.json": "8e1235f0f0d89d81c9aafe8e4eac4a4dc3521c1b583c845b15595ddeecc7c0c2", + "main.js": "6dd3bf43dce74236d4904c4e33639772ef03bd4cd80d6e5a4532ff7ca7ed085a", "styles.css": "14d374b5d0e1461cb1ca2b125865e9c27df7c3bd79c11caa0afc52152c7d0aef" } },