11

I'm looking for an angular virtual scroll package with following functionality: 1) Horizontal virtual scroll 2) Container width and height are fluid. 3) Items width set in percentage of the container width. 4) Items can be minimized during render.

Angular cdk currently works with fixed itemSize for height and width.... here is an example of how it should be rendered:

.parent {
  width: 100%;
  height: 100%;
  display: flex;
  padding: 10px;
}
.child {
  width: 33.333%;
  height: 100%;
}
.child.mini {
  width: 40px;
}
<div class="parent">
  <div class="child" *ngFor="let item of items" [class.mini]="item.isMini">
    <button (click)="item.isMini = !item.isMini">Minimize Me!</button>
    {{item.name}}
  </div>
</div>

Any recommendation?

4
  • 1
    Any solution? I have the same "problem"
    – pauloh
    Commented May 12, 2019 at 23:36
  • 1
    Ended up using ngx-scroller. The only thing it doesn't support is ltr.
    – Itai
    Commented May 19, 2019 at 9:15
  • Do you mean rtl? Does it have any effect when the list is vertically oriented? Commented Jun 17, 2019 at 8:46
  • I meant rtl. I don't think it should affect a vertical list
    – Itai
    Commented Jun 17, 2019 at 9:45

4 Answers 4

6

The Angular team is working on an autosize directive which enables scrolling with different items sizes.

You can see an example using @angular/cdk-experimental here .
Keep in mind that this is EXPERIMENTAL and is not recommended for production use at the moment, but it does give you the feel and if you really need it, it could help.

Also, check out the github issue

5

You may try ngx-ui-scroll. Speaking of your requirements, it supports

Not sure about %-base dimensions, I suppose you'll have to reconsider the templating in you app. Templating and data flow... Hope this helps.

2

The ag-virtual-scroll component give support the virtual scroll with differents row height, but the scroll works only vertical.

NPM: https://www.npmjs.com/package/ag-virtual-scroll

DEMO PAGE: https://ericferreira1992.github.io/ag-virtual-scroll/ (second example)

1
  • This works pretty well for simple cases, and even has Magic (TM) that gives tables sticky headers. Couldn't go with it in the end though, as the grid shenannigans I tried with it made it rather unhappy.
    – Fasteroid
    Commented May 2 at 18:46
-2

If you do not want to autosize directive as earlier mentioned,

Here is an alternative way:

I have solved the issue by dynamically passing in the height value:

<cdk-virtual-scroll-viewport #scrollViewport 
[itemSize]="itemSize" [style.height.px]="viewPortHeight">
</cdk-virtual-scroll-viewport>

Note that: my viewport component was put within an <ng-template>;

itemSize and viewPortHeight are variables defined in the context.

Not the answer you're looking for? Browse other questions tagged or ask your own question.