fix(album): 点击处理读最新 node(连点模式开关失效)+ 可点击 span 挡 pointerdown(翻页/密度不响应)
validate / validate (push) Canceled after 0s
validate / validate (push) Canceled after 0s
This commit is contained in:
1 parent
37c7c4b666
commit
d43b1520dc
1 file changed
+15
-8
+15
-8
@@ -44,6 +44,13 @@
|
||||
}
|
||||
return node
|
||||
}
|
||||
// 可点击元素:宿主在节点体上的 pointerdown 会启动「拖动节点」,单击事件因此被吞。
|
||||
// 所有可点击的非 input/button 元素都必须挡住 pointerdown(与 ui-node-bodies 里 stop 的用法一致)。
|
||||
function onTap (el0, fn) {
|
||||
el0.addEventListener('pointerdown', (e) => e.stopPropagation())
|
||||
el0.addEventListener('click', (e) => { e.stopPropagation(); fn(e) })
|
||||
return el0
|
||||
}
|
||||
function hash32 (s) {
|
||||
let h = 0x811c9dc5
|
||||
const str = String(s || '')
|
||||
@@ -123,9 +130,12 @@
|
||||
modeLabel.addEventListener('pointerdown', (e) => e.stopPropagation())
|
||||
modeLabel.addEventListener('click', (e) => {
|
||||
e.stopPropagation()
|
||||
const d = (node && node.data) || {}
|
||||
// ⚠ 必须读 st.node(每次 sync 更新),不能读 buildShell 捕获的 node ——
|
||||
// 那是**挂载时**的旧数据,连点两次会一直算出同一个 next(实测:永远停在批量)。
|
||||
const cur = st.node || node
|
||||
const d = (cur && cur.data) || {}
|
||||
const next = d.albumMode === 'batch' ? 'per-image' : 'batch'
|
||||
update(props, node, { albumMode: next })
|
||||
update(st.props || props, cur, { albumMode: next })
|
||||
})
|
||||
const count = el('span', { className: 'iwb-album-count' })
|
||||
bar.appendChild(modeLabel); bar.appendChild(count)
|
||||
@@ -136,8 +146,7 @@
|
||||
const seg = el('span', { className: 'iwb-album-seg' })
|
||||
const segs = {}
|
||||
for (const key of ['S', 'M', 'L']) {
|
||||
const s = el('span', { title: key === 'S' ? '小格(默认)' : (key === 'M' ? '中格' : '大格') }, key)
|
||||
s.addEventListener('click', (e) => { e.stopPropagation(); update(props, node, { density: key }) })
|
||||
const s = onTap(el('span', { title: key === 'S' ? '小格(默认)' : (key === 'M' ? '中格' : '大格') }, key), () => update(st.props || props, st.node || node, { density: key }))
|
||||
segs[key] = s; seg.appendChild(s)
|
||||
}
|
||||
const tools = el('div', { className: 'iwb-album-tools' }, [btnAdd, btnDir, btnSettle, seg])
|
||||
@@ -225,10 +234,8 @@
|
||||
if (showPager) {
|
||||
st.pager.innerHTML = ''
|
||||
const pg = el('span', { className: 'iwb-album-pg' })
|
||||
const prev = el('span', { title: '上一页' }, '‹')
|
||||
const next = el('span', { title: '下一页' }, '›')
|
||||
prev.addEventListener('click', (e) => { e.stopPropagation(); if (page > 0) update(st.props, st.node, { page: page - 1 }) })
|
||||
next.addEventListener('click', (e) => { e.stopPropagation(); if (page < pages - 1) update(st.props, st.node, { page: page + 1 }) })
|
||||
const prev = onTap(el('span', { title: '上一页' }, '‹'), () => { if (page > 0) update(st.props, st.node, { page: page - 1 }) })
|
||||
const next = onTap(el('span', { title: '下一页' }, '›'), () => { if (page < pages - 1) update(st.props, st.node, { page: page + 1 }) })
|
||||
pg.appendChild(prev); pg.appendChild(el('b', null, (page + 1) + '/' + pages)); pg.appendChild(next)
|
||||
st.pager.appendChild(pg)
|
||||
const only = el('label', { className: 'iwb-album-mini' }, [
|
||||
|
||||
Reference in new issue
Block a user