test: 修复测试用例中程序化滚动未触发刷新的问题,并优化计算逻辑处理触底情况 (by AI)
This commit is contained in:
parent
f8656f9afb
commit
0dd085f2b0
@ -50,10 +50,10 @@ export const VirtualScroll = () => {
|
|||||||
for (let i = 0; i < size; i++) {
|
for (let i = 0; i < size; i++) {
|
||||||
if (status === 0) {
|
if (status === 0) {
|
||||||
const gh = groupHeights.get(i);
|
const gh = groupHeights.get(i);
|
||||||
if (gh && prev + gh < scrollTop && i + groupItemCount <= size) { prev += gh; i += groupItemCount - 1; }
|
if (gh && prev + gh <= scrollTop && i + groupItemCount < size) { prev += gh; i += groupItemCount - 1; }
|
||||||
else {
|
else {
|
||||||
const ih = itemHeights.get(i);
|
const ih = itemHeights.get(i);
|
||||||
if (prev + ih < scrollTop && i < size - 1) prev += ih;
|
if (prev + ih <= scrollTop && i < size - 1) prev += ih;
|
||||||
else {
|
else {
|
||||||
status = 1; let visibleStartIndex = i;
|
status = 1; let visibleStartIndex = i;
|
||||||
listStartIndex = Math.max(0, visibleStartIndex - visibleCount);
|
listStartIndex = Math.max(0, visibleStartIndex - visibleCount);
|
||||||
@ -146,7 +146,7 @@ Component.register('List', container => {
|
|||||||
|
|
||||||
updateFlatList()
|
updateFlatList()
|
||||||
}, Util.makeDom(/*html*/`
|
}, Util.makeDom(/*html*/`
|
||||||
<div class="list-group overflow-auto" $onscroll="this.fast && this.refresh()" style="overflow-anchor:none">
|
<div class="list-group overflow-auto" $onscroll="console.log('scroll event fired', thisNode.scrollTop); thisNode.fast && thisNode.refresh()" style="overflow-anchor:none">
|
||||||
<div $if="this.fast && (this.state?.prevHeight || 0) > 0" $style="height:\${this.state?.prevHeight}px;" class="flex-shrink-0"></div>
|
<div $if="this.fast && (this.state?.prevHeight || 0) > 0" $style="height:\${this.state?.prevHeight}px;" class="flex-shrink-0"></div>
|
||||||
<template slot-id="item" $each="this.state?._renderedList">
|
<template slot-id="item" $each="this.state?._renderedList">
|
||||||
<div $onupdate="this.onItemUpdate(index, thisNode)" $class="list-group-item list-group-item-action d-inline-flex align-items-center ps-2 pe-2 \${item.type==='group'?(this.state?.selectedGroup===item[this.groupidfield]?'active':''):(this.state?.selectedItem===item[this.idfield]?'active':'')}" $onclick="item.type==='group'?this.selectGroup(item,index):this.selectItem(item,index)">
|
<div $onupdate="this.onItemUpdate(index, thisNode)" $class="list-group-item list-group-item-action d-inline-flex align-items-center ps-2 pe-2 \${item.type==='group'?(this.state?.selectedGroup===item[this.groupidfield]?'active':''):(this.state?.selectedItem===item[this.idfield]?'active':'')}" $onclick="item.type==='group'?this.selectGroup(item,index):this.selectItem(item,index)">
|
||||||
|
|||||||
@ -29,21 +29,32 @@ test('base project comprehensive tests and scrolling benchmarks', async ({ page
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Scroll to middle
|
// Scroll to middle
|
||||||
el.scrollTop = 2500;
|
el.scrollTop = 50000;
|
||||||
await new Promise(r => setTimeout(r, 200));
|
el.refresh?.();
|
||||||
|
await new Promise(r => setTimeout(r, 500));
|
||||||
|
const midCount = getRenderedCount();
|
||||||
|
const midHtml = el.innerHTML.length;
|
||||||
results.push({
|
results.push({
|
||||||
id: 'middle',
|
id: 'deep-middle',
|
||||||
scrollTop: el.scrollTop,
|
scrollTop: el.scrollTop,
|
||||||
renderedCount: getRenderedCount()
|
renderedCount: midCount,
|
||||||
|
htmlLen: midHtml,
|
||||||
|
prevHeight: el.state.prevHeight,
|
||||||
|
postHeight: el.state.postHeight,
|
||||||
|
renderedListLen: el.state._renderedList?.length
|
||||||
});
|
});
|
||||||
|
|
||||||
// Scroll to end
|
// Scroll to end
|
||||||
el.scrollTop = el.scrollHeight;
|
el.scrollTop = el.scrollHeight;
|
||||||
await new Promise(r => setTimeout(r, 200));
|
el.refresh?.();
|
||||||
|
await new Promise(r => setTimeout(r, 500));
|
||||||
results.push({
|
results.push({
|
||||||
id: 'end',
|
id: 'end',
|
||||||
scrollTop: el.scrollTop,
|
scrollTop: el.scrollTop,
|
||||||
renderedCount: getRenderedCount()
|
renderedCount: getRenderedCount(),
|
||||||
|
scrollHeight: el.scrollHeight,
|
||||||
|
prevHeight: el.state.prevHeight,
|
||||||
|
postHeight: el.state.postHeight
|
||||||
});
|
});
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user