From 89bb19beab08752aed441ae6abf1cedcf959d833 Mon Sep 17 00:00:00 2001 From: qiqi Date: Sat, 28 Nov 2026 08:17:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(gallery):=201.9.4=20=E6=B6=88=E9=99=A4?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E5=8A=A0=E8=BD=BD=E6=97=B6=E7=9A=84=E9=97=AA?= =?UTF-8?q?=E5=8A=A8=E2=80=94=E2=80=94=E5=8D=A1=E7=89=87=E6=8C=89=E5=AE=BD?= =?UTF-8?q?=E9=AB=98=E6=AF=94=E5=8D=A0=E4=BD=8D=20+=20=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E8=A7=A3=E7=A0=81=20+=20=E5=8A=A0=E5=A4=A7=E9=A2=84=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 闪动的来源:卡片初始只有「加载中…」那一行字的高度,缩略图一到就从一行字长成整图高, 整列跟着重排,滚动时看起来就是闪一下。 - itemNode:按 it.w/it.h 给卡片设 aspect-ratio,占位阶段就占好最终高度;有宽高时占位文案不写「加载中…」 - styles.css:占位层 absolute inset:0 铺满卡片(否则卡片高了、占位还是 84px 的小框) - img 插入后调用 decode(),解码不占主线程 - 预取范围从 0.8/1.8 屏提到 1.2/2.4 屏,滚动时少触发几次窗口重排 --- plugins/gallery/main.js | 10 +++++++--- plugins/gallery/manifest.json | 6 +++--- plugins/gallery/styles.css | 2 ++ plugins/index.json | 8 ++++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/plugins/gallery/main.js b/plugins/gallery/main.js index 79528c5..909e50b 100644 --- a/plugins/gallery/main.js +++ b/plugins/gallery/main.js @@ -425,8 +425,8 @@ if (!force && winState.top >= 0 && grid.firstChild && Math.abs(top - winState.top) < viewH * 0.6 && winState.viewH === viewH) return winState.top = top winState.viewH = viewH - var from = Math.max(0, top - viewH * 0.8) - var to = top + viewH * 1.8 + var from = Math.max(0, top - viewH * 1.2) + var to = top + viewH * 2.4 clear(grid) for (var ci = 0; ci < L.cols.length; ci++) { var colDef = L.cols[ci] @@ -476,7 +476,10 @@ origBadge = el('span', { class: 'iwb-gal-origbadge', text: it.orig === 'off' ? '未备份' : '仅缩略图' }) origBadge.title = it.orig === 'off' ? '原图入库已关闭:这张只有缩略图' : '原图没有写进本地:右键可「补存原图」' } - var holder = el('div', { class: 'iwb-history-missing', text: '加载中…' }) + // v1.9.4:卡片先按宽高比占位 —— 否则缩略图出现的瞬间卡片从「一行字高」长成整图高, + // 整列跟着重排,滚动时就表现为闪动。 + if (it.w && it.h) { try { box.style.aspectRatio = it.w + ' / ' + it.h } catch (e0) { /* ignore */ } } + var holder = el('div', { class: 'iwb-history-missing', text: it.w && it.h ? '' : '加载中…' }) box.appendChild(holder) var tries = 0 function fail (text) { @@ -516,6 +519,7 @@ // 放弃会导致某些卡片永远停在「加载中…」(缩略图缓存已存,只是没人把它挂上去)。 var img = el('img', { src: url, alt: '', loading: 'eager', decoding: 'async', draggable: 'true' }) if (it.w && it.h) img.setAttribute('style', 'aspect-ratio:' + it.w + ' / ' + it.h) + try { if (typeof img.decode === 'function') img.decode().catch(function () {}) } catch (e4) { /* ignore */ } img.addEventListener('load', function () { // naturalWidth=0 说明拿到的是坏图(空 data URL / 截断文件):按失败处理,别留白块 if (!img.naturalWidth) { tries++; if (tries <= 2) { setTimeout(boot, 400 * tries); return } if (img.parentNode === box) box.replaceChild(holder, img); fail('缩略图加载失败(点击重试)'); return } diff --git a/plugins/gallery/manifest.json b/plugins/gallery/manifest.json index e4d416e..b97b287 100644 --- a/plugins/gallery/manifest.json +++ b/plugins/gallery/manifest.json @@ -1,7 +1,7 @@ { "id": "gallery", "name": "图库", - "version": "1.9.3", + "version": "1.9.4", "apiVersion": 1, "main": "main.js", "style": "styles.css", @@ -13,7 +13,7 @@ "图库" ], "files": { - "main.js": "0921ffa067b14de54aeabf5a46cd29a4a2bad2b8d2bd086600324ca7506385d9", - "styles.css": "945fd547278cf0388035b22660dfe9401dc0c8d25919fe6204471432e5797cde" + "main.js": "acfa2c21c22afef3d05f21b38cfc36286f89ac20342b7d985d9da8873e99c18e", + "styles.css": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d" } } diff --git a/plugins/gallery/styles.css b/plugins/gallery/styles.css index 5103fbd..8f088eb 100644 --- a/plugins/gallery/styles.css +++ b/plugins/gallery/styles.css @@ -80,6 +80,8 @@ border-color: var(--iwb-hover-border, var(--iwb-brand)); box-shadow: var(--iwb-hover-shadow, 0 5px 16px rgba(0, 0, 0, .22)); } +/* v1.9.4:卡片按宽高比占位后,占位层要铺满卡片 —— 否则缩略图出现时仍会有一次高度跳变(滚动时表现为闪动) */ +.iwb-history-embedded .iwb-history-item .iwb-history-missing { position: absolute; inset: 0; min-height: 0; } .iwb-history-missing { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 84px; padding: 8px; border-radius: 6px; border: 1px dashed var(--iwb-border); diff --git a/plugins/index.json b/plugins/index.json index 9e823c9..3fff0be 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -33,11 +33,11 @@ "dir": "gallery", "main": "main.js", "style": "styles.css", - "version": "1.9.3", + "version": "1.9.4", "files": { - "manifest.json": "62380d625ff676d434d066a6800eccedce224a3a0a4ded83f98459dc60f7c57f", - "main.js": "0921ffa067b14de54aeabf5a46cd29a4a2bad2b8d2bd086600324ca7506385d9", - "styles.css": "945fd547278cf0388035b22660dfe9401dc0c8d25919fe6204471432e5797cde" + "manifest.json": "c083bfd23a1dc2aaa540ad246f3ee3f15e7b00c8d5e7ef7c2ccf4809e6673f2b", + "main.js": "acfa2c21c22afef3d05f21b38cfc36286f89ac20342b7d985d9da8873e99c18e", + "styles.css": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d" } }, {