tnfe / vue3-infinite-list Goto Github PK
View Code? Open in Web Editor NEW一个支持百万数量级的Vue3无限滚动列表组件
Home Page: https://tnfe.github.io/vue3-infinite-list
一个支持百万数量级的Vue3无限滚动列表组件
Home Page: https://tnfe.github.io/vue3-infinite-list
while (offset < maxOffset && stop < this.itemCount - 1) {
stop++;
offset += this.getSizeAndPositionForIndex(stop).size;
}
这一段判断变成了 offset < '100%'
scrollOffset = 21959
debug打印 = start:209 stop:337 total:410 offset:21959
事件返回e.target.scrollTop = 20285
debug打印 = start:188 stop:316 total:410 offset:20285
可以实现鼠标悬停 停止自动滚动功能吗?
:data="dataSource"
dataSource一直在变化,是proxy对象,页面没有变化
README.zh-CN.md 中文翻译有问题,这不叫无限滚动加载库吧,本身没有判断滚动到底后的加载事件,需要额外编写监听滚动事件进行加载。最多叫无限列表。
如果渲染一千万条数据,整个盒子高度会很大,但实际盒子最大高度只能到26843542像素,就可能会造成滚到底部依然无法渲染后面的数据的问题。
<div v-for="(col, iCol) in dl.lst" :key="iCol class="col c2 h-[168px] text-center " ">
<div class="cell border-b border-slate-500 w-[26px] h-[26px] text-center overflow-hidden "
v-for="(c, iRow) in col" :key="iRow">
<img v-if="c >= 100" :src="'/static/img/dl-' + c + '.png'" alt=""
class="h-[100%] w-full align-center p-[2px] ">
</div>
</div>
您好,
我想增加多选框怎么做?希望多选框能选中一整行。
我的应用场景是有很多的列。
高度不确定的情况如何动态渲染高度,我看getItemSize这个函数只能返回索引
实际使用中发现,itemSize不填会报错。看文档显示是非必填属性
Dynamic data seems to not be 100%.
Let's say I have a list of 10000 items, and a search bar.
I start typing in search bar, which shrinks my data to say 100 items. Vue3-infinite-list crashes with:
Uncaught (in promise) Error: Requested index 28 is outside of range 0..28
at SizeAndPosManager.getSizeAndPositionForIndex (vue3-infinite-list.es.js:90:1)
at Proxy.getItemStyle (vue3-infinite-list.es.js:344:39)
at vue3-infinite-list.es.js:524:32
at renderList (runtime-core.esm-bundler.js:6497:1)
at Proxy._sfc_render (vue3-infinite-list.es.js:521:70)
at renderComponentRoot (runtime-core.esm-bundler.js:893:1)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5098:1)
at ReactiveEffect.run (reactivity.esm-bundler.js:167:1)
at updateComponent (runtime-core.esm-bundler.js:4968:1)
at processComponent (runtime-core.esm-bundler.js:4901:1)
I think the logic needs to be adjusted to deal with being scrolling past the end of the data?
列表项的高度完全由实际渲染决定,不再设置(itemSize)之类任何的有关高度的设置。完全预估形式的,这样比itemSize来的更加有特色。可能性能上稍逊。
ps:可以参考这个库的预估高度思路
高度Height一定要设置吗? 数据量很多的时候,Height 也要list.length * itemHeight吗? 这样会导致卡死啊,特别是跟走马灯一起用的时候
When my data object changes (such as the state of an item affecting a button color), I find that dom actually hasn't changed.
I analyzed the source code and found that the code shown below caused the dom rendering delay issue due to setTimeout.
index.vue line 313
watch( () => props.data, (newVal, oldVal) => { ... setTimeout(scrollRender, 0); } );
I changed this to directly run scrollRender()
instead of run setTimeout
, and DOM promptly rendered the latest item state.
Why use setTimeout
here?
The code in the scrollRender function not needs to wait a period of time before running.
Because in other watch
, scrollRender
is directly called, and if it is necessary to perform certain tasks after updating the DOM, vue nextTick
can also be used to replace setTimeout
.
If possible, I have a suggestion:
scrollRender
so that the renderEnd
function for DOM operations is not placed in the scrollRender
function.watch
part, directly run scrollRender()
, and then call await nextTick(renderEnd)
假设一次性接收几千条数据,但是我只希望一次展示30条,滚动到底部触发事件后展示更多,该怎么做呢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.