-
Notifications
You must be signed in to change notification settings - Fork 11
Home
A-JIE edited this page Nov 1, 2017
·
3 revisions
Using npm:
npm install angular-infinite-list --save
import { InfiniteListModule } from 'angular-infinite-list';
@NgModule({
imports: [
BrowserModule,
FormsModule,
InfiniteListModule,
...
<infinitelist
[width]='"100%"'
[height]='500'
[data]='data'
[itemSize]='50'
(update)='event = $event'>
<div *ngFor="let item of event?.items; let i=index;" [ngStyle]="event.getStyle(i)">
item{{event.start + i}} : {{item|json}}
</div>
</infinitelist>
or directive usage
<div infinitelist [width]='"100%"' ...</div>
Because in the angular all the asynchronous operation will cause change detection.High-frequency operations such as the scroll event can cause significant performance losses.
So in some high-precision scenes, we can use rxjs Observable to solve. About angular asynchronous, change detection checks and zone.js. You can view it zone.js and change detection
You can switch to the Observable mode. of course, if your scene on the efficiency requirements are not high can not do so.
<infinitelist
[[width]='"100%"'
[height]='500'
[data]='data'
[itemSize]='150'
[useob]='true'
(update)='update($event)'>
<div class="li-con" *ngFor="let item of event?.items; let i=index;" [ngStyle]="event.getStyle(i)">
item{{event.start + i}}
</div>
</infinitelist>
event: ILEvent;
constructor(private cdRef: ChangeDetectorRef) { }
update($event: Subject<any>) {
$event.subscribe(x => {
this.event = x;
this.cdRef.detectChanges();
});
}