Skip to content

Commit

Permalink
Merge pull request #57 from dhilt/first-visible
Browse files Browse the repository at this point in the history
Adapter.firstVisible implementation
  • Loading branch information
dhilt authored Jul 25, 2018
2 parents d51ed8a + ae3920a commit 5c6589e
Show file tree
Hide file tree
Showing 25 changed files with 224 additions and 137 deletions.
15 changes: 12 additions & 3 deletions demo/app/samples/test.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
<br>
<small>ngx-ui-scroll version: {{datasource.adapter.version}}</small>
<br>
<small>isLoading: {{datasource.adapter.isLoading}}</small>
<small>isLoading:
{{datasource.adapter.isLoading}}
({{(datasource.adapter.isLoading$ | async)}})
</small>
<br>
<small>first visible:
{{datasource.adapter.firstVisible.$index}}
({{(datasource.adapter.firstVisible$ | async)?.$index}})
</small>
<br><br>
</div>

<div class="viewport" style="height: 600px">
<!--<div style="height: 100px">gap</div>-->
<div *uiScroll="let item of datasource">
<app-samples-test-inner>{{item.text}}</app-samples-test-inner>
<app-samples-test-inner>
{{item.text}} {{item.id % 10 === 0 ? '**********' : ''}}
</app-samples-test-inner>
</div>
</div>
8 changes: 6 additions & 2 deletions demo/app/samples/test.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component } from '@angular/core';
import { Observable, Observer } from 'rxjs';
import { switchMap } from 'rxjs/operators';

import { Datasource } from '../../../public_api'; // from 'ngx-ui-scroll';

const MAX = 500;
const MIN = 1;
const MIN = -1000;

@Component({
selector: 'app-samples-test-inner',
Expand Down Expand Up @@ -33,6 +34,10 @@ export class TestComponent {
text: 'item #' + (i + MIN)
});
}
this.datasource.adapter.firstVisible$
.subscribe((value) => {
console.log('..............................first visible item:', value);
});
}

datasource = new Datasource({
Expand All @@ -48,7 +53,6 @@ export class TestComponent {
});

doReload() {
// this.data.forEach(item => item.text += '+');
this.datasource.adapter.reload(this.reloadIndex);
}

Expand Down
2 changes: 1 addition & 1 deletion package-dist.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-ui-scroll",
"version": "0.0.5",
"version": "0.0.6",
"description": "Infinite/virtual scroll for Angular",
"main": "./bundles/ngx-ui-scroll.umd.js",
"module": "./esm5/ngx-ui-scroll.js",
Expand Down
Loading

0 comments on commit 5c6589e

Please sign in to comment.