簡體   English   中英

如何使用 angular cdk 虛擬滾動一次滾動兩個列表?

[英]How to scroll two lists at once with angular cdk virtual scroll?

我想做這樣的事情:

<cdk-virtual-scroll-viewport [itemSize]="25">
  <svg>
    <g *cdkVirtualFor="let item of items">...</g>
  </svg>
  <div *cdkVirtualFor="let item of items">...</div>
</cdk-virtual-scroll-viewport>

並讓gdiv元素同時滾動(它們都具有相同的高度)。 這可能嗎? 完全按照我在此處概述的操作會導致錯誤: Error: CdkVirtualScrollViewport is already attached.

以下是我如何使用虛擬滾動實現 2 個列表:我組合了列表,添加了一個類型,按類型對列表進行排序,並在類型更改時中斷:

ts file:
    didGroupChange(jobNow:JobsResponse, jobPrev:JobsResponse){
            return jobNow.type!==jobPrev?.type;
        }
HTML:
    <cdk-virtual-scroll-viewport [itemSize]="20" class="scroll-panel-jobs">                         
    <dl>
        <ng-container *cdkVirtualFor="let job of  country?.jobsList;  let index = index;">
             <dt *ngIf="didGroupChange(job,country?.jobsList[index-1])" class="line row h15 title-job">{{job.type}}</dt>    
             <dd class="line row h16">{{job.title}} </dd>                     
        </ng-container>
      </dl>                 
</cdk-virtual-scroll-viewport>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM