我已经更新了你的代码并添加了属性
我使用的是cdk-virtual-scroll
不使用css属性scroll-snap-type
也可以正常工作。
当我使用scroll-snap-type
时,它闪烁几秒钟。我附上了代码样本https://stackblitz.com/edit/angular-gchlgl?file=src%2Fstyles.scss, src % 2 fapp % 2 fcdk-virtual-scroll-data-source-example.css src % 2 fapp % 2 fcdk-virtual-scroll-data-source-example.html
帮忙吗?谢谢。
如果你使用cdk-virtual-scroll
,你应该定义你的容器和项目的确切像素大小。因为itemSize
属性定义了项目的大小。所以在你的代码中,项目的大小是相同的,但在响应大小(不固定使用像素),但你定义的itemSize
是740px。我认为这将是崩溃的cdk-virtual-scroll
,以提高您的网站的性能,同时做计算渲染很多项目。
我已经更新了你的代码并添加了属性
itemSize
,minBufferPx
,maxBufferPx
: