fix(dock/gallery): 图库图幅自适应重做 + 左右栏快捷键 n/t + 面板层级与滚轮修正 v3.25.38
- 图库列数改为按「面板宽 / 图幅」计算(图幅可选 110/130/170/220,默认 130,持久化), 同一图幅下列宽稳定、只靠增减列数适应面板宽度;去掉 460px 上下限(竖图不再被 letterbox 缩成小图) - 图库头部 flex-wrap:窄面板自动两行,按钮不被挤压 - n = 右栏开合、t = 左栏开合;顶栏「图库」按钮与其快捷键一并下线(帮助/设置文案同步) - 左右栏从标签条下方开始(top:36px),标签条恢复满宽并压在面板之上;首页/落地页隐藏停靠栏 (原生子 webview 因 rect 归零被 park,不再盖住首页) - 停靠栏在 .iwb-canvas 内 ⇒ 面板根节点吞掉 wheel/pointerdown/contextmenu,画布 wheel 白名单补 .iwb-dock;图库网格 overscroll-behavior:contain - 图库宽度测量改为可重挂(面板延迟挂载时不再固定按 300 计算列宽)
This commit is contained in:
1 parent
1d44e04d96
commit
540da6deba
17 files changed
+105
-74
No files matched your search
@@ -1153,16 +1153,36 @@
|
||||
|
||||
// ── 画布视图类 effect / 纯计算(2026-11-06 从 Workbench 外移)─────────────────────
|
||||
// 图库容器宽度测量(瀑布流列数自适应);返回 cleanup
|
||||
// ⚠️ 图库现在挂在右停靠栏里,是**延迟挂载**的(面板切换/插件异步注册都会重建 DOM):
|
||||
// 旧实现只在 effect 首次执行时取一次 ref,ref 为空就直接放弃 ⇒ histGridW 永远停在 300,
|
||||
// 列宽按 300 算、实际容器却可能是 500,图片就会「有时很大、有时很小」。
|
||||
// 改为定期尝试挂上(只读一个 ref,开销可忽略),元素换了(React 重建)就重挂。
|
||||
function startGalleryMeasure(ctx) {
|
||||
const { histGridRef, setHistGridW } = ctx
|
||||
const el0 = histGridRef && histGridRef.el
|
||||
if (!el0) return undefined
|
||||
const measure = () => { if (el0.clientWidth > 0) setHistGridW(el0.clientWidth) }
|
||||
measure()
|
||||
let el0 = null
|
||||
let ro = null
|
||||
const measure = () => { if (el0 && el0.clientWidth > 0) setHistGridW(el0.clientWidth) }
|
||||
const attach = () => {
|
||||
const next = histGridRef && histGridRef.el
|
||||
if (!next || next === el0) return false
|
||||
el0 = next
|
||||
measure()
|
||||
if (typeof ResizeObserver !== 'undefined') {
|
||||
if (ro) { try { ro.disconnect() } catch (e) { /* ignore */ } }
|
||||
ro = new ResizeObserver(measure)
|
||||
ro.observe(el0)
|
||||
}
|
||||
return true
|
||||
}
|
||||
attach()
|
||||
const iv = setInterval(attach, 800)
|
||||
window.addEventListener('resize', measure)
|
||||
const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(measure) : null
|
||||
if (ro) ro.observe(el0)
|
||||
return () => { window.removeEventListener('resize', measure); if (ro) ro.disconnect() }
|
||||
return () => {
|
||||
clearInterval(iv)
|
||||
window.removeEventListener('resize', measure)
|
||||
if (ro) { try { ro.disconnect() } catch (e) { /* ignore */ } }
|
||||
el0 = null
|
||||
}
|
||||
}
|
||||
|
||||
// wheel 缩放 + 画布尺寸跟随;返回 cleanup
|
||||
@@ -1174,7 +1194,7 @@
|
||||
if (refs.zoomAnim) { cancelAnimationFrame(refs.zoomAnim); refs.zoomAnim = null }
|
||||
// 面板区域(抽屉/历史图/工具栏/侧栏/弹窗等)滚轮只滚动内容,不缩放画布
|
||||
const t0 = e.target
|
||||
if (t0 && t0.closest && t0.closest('.iwb-drawer, .iwb-toolbar, .iwb-rightrail, .iwb-wsrail, .iwb-statusbar, .iwb-minimap, .iwb-hint-bottom, .iwb-lib, .iwb-modal, .iwb-fullpanel')) return
|
||||
if (t0 && t0.closest && t0.closest('.iwb-dock, .iwb-drawer, .iwb-toolbar, .iwb-rightrail, .iwb-wsrail, .iwb-statusbar, .iwb-minimap, .iwb-hint-bottom, .iwb-lib, .iwb-modal, .iwb-fullpanel')) return
|
||||
e.preventDefault()
|
||||
// 标记"缩放窗口"(去抖 160ms):缩放下每帧会生成新的 nodes 数组,让节点 memo 在此期间放宽比较
|
||||
try {
|
||||
@@ -1315,12 +1335,13 @@
|
||||
|
||||
// 图库瀑布流分列:贪心最短列(保持时间顺序),列数随容器宽度自适应
|
||||
function computeHistColumns(ctx) {
|
||||
const { histFilteredFallback, histGridW, histLimit } = ctx
|
||||
const { histFilteredFallback, histGridW, histLimit, histTile } = ctx
|
||||
const vis = histFilteredFallback.slice().sort((a, b) => (b.mtime || 0) - (a.mtime || 0)).slice(0, histLimit)
|
||||
if (!vis.length) return { buckets: [], colW: 0 }
|
||||
const w = histGridW > 0 ? histGridW : 300
|
||||
const colCount = Math.max(2, Math.min(4, Math.round(w / 130)))
|
||||
const gap = 8
|
||||
const tw = histTile > 0 ? histTile : 130
|
||||
const colCount = Math.max(1, Math.floor((w + gap) / (tw + gap)))
|
||||
const colW = (w - gap * (colCount - 1)) / colCount
|
||||
const buckets = Array.from({ length: colCount }, () => [])
|
||||
const heights = Array(colCount).fill(0)
|
||||
|
||||
Reference in new issue
Block a user