滚动闪烁问题 - 使用scroll-snap型的CDK-Virtual-Scroll
我正在使用 cdk-virtual-scroll 。
它在不使用CSS属性 scroll-snap-type
的情况下工作正常。
当我使用滚动snap-type
时,它会闪烁几秒钟。我附上了代码样本
https://stackblitz.com/edit/Edit/Angular-gular-gchlgl?file=src%2fstyles.scss.scss,scs,src,src%2fapp; scroll-data-source-example.css,src%2FAPP%2fcdk-virtual-scroll-scroll-data-source-example.html
有帮助吗?谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是
cdk-virtual-scroll
,则应定义容器和物品的精确像素大小。因为itextize
属性正在定义项目的大小。因此,在您的代码中,项目的大小相同,但响应大小(未使用像素固定),但您定义itextize
为740px。我认为这将崩溃cdk-virtual-scroll
,以提高网站的性能,同时计算渲染很多项目。我已经更新您的代码并添加属性
itextize
,minbufferpx
,maxBufferpx
:请参阅demo:
stackblitz CSS属性到固定尺寸:
CSS
If you are using
cdk-virtual-scroll
, you should define the exact pixel size of your container and item. BecauseitemSize
attribute is defining the size of the item. So in your code, the size of the items are same but in responsive size (not fixed using pixel), but you define theitemSize
is 740px. I thought that will be crash thecdk-virtual-scroll
to improve performance of your website while doing the calculation of rendering a lot of items.I've update your code and add attributes
itemSize
,minBufferPx
,maxBufferPx
:SEE DEMO: StackBlitz
HTML
And update some responsive CSS properties to fixed size:
CSS