od-virtualscroll icon indicating copy to clipboard operation
od-virtualscroll copied to clipboard

Prefered way to force redraw of rows/items.

Open ktersius opened this issue 7 years ago • 5 comments

Currently when options like item sizes are changed I have to somehow force the component to redraw. It seems that emitting the options itself is not enough to trigger any sort of redraw.

If I only emit options they seem to only take effect as I scroll through the items and the rows are updated.

For now I'm emitting an empty array and then right after that the data array, this seems to make it redraw but it feels messy.

 subs.push(this.debounceResize$.subscribe(() => {
        observer.next([]);
        observer.next(curData);
      }));

ktersius avatar Jun 22 '17 12:06 ktersius

Hi @ktersius, yeah, this is an issue I am aware of and I will look into it. The reason I did not implement it in the first place is that I was unsure, whether it could harm the performance or not. But as there seems to be a use case, I will evaluate the practicability. Thanks!

dinony avatar Jul 04 '17 13:07 dinony

Yup, I met the same problem today, but I solved it by this tricky way.

In templates

<od-virtualscroll [vsData]="data$" [vsOptions]="options$">
...
</od-virtualscroll>

In components

data$ = new Subject<number[]>();

change() {
    // use this to force redraw
    this.data$.next([]);
    this.data$.next(new Array(100).fill(0).map(x => Math.floor(Math.random() * 1000)));
}

musicq avatar May 08 '18 07:05 musicq

Yeah thanks. But it's still something, which needs to be addressed in future. I hope I will find some time for another maintenance/feature request round.

dinony avatar May 08 '18 08:05 dinony

Have you had a chance to look into this? I'm facing a similar issue.

furlongce avatar Aug 02 '18 19:08 furlongce

Not yet, but I (or someone else :+1:) will!

dinony avatar Aug 03 '18 18:08 dinony