Skip to content

Commit

Permalink
Creative chaos (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyuvzhenko committed Dec 16, 2017
1 parent c7a41e9 commit 99ed60d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ <h1>

<div *uiScroll="let item of datasource">
Hello uiScroll Directive.<b>{{item}}</b>
</div>
</div>
31 changes: 16 additions & 15 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ export class AppComponent {
private test: Boolean = true;

private datasource = {
test: [1,2,3,4,5,6,7,8,7,6,5,4,3,2,1,0],
get: (index: number, count: number) => Observable.create(observer => {
console.log('requested index = ' + index + ', count = ' + count);
setTimeout(() => {
let data = [];
for (let i = index; i <= index + count - 1; i++) {
data.push({
id: i,
text: "item #" + i
});
}
console.log('resolved ' + data.length + ' items (index = ' + index + ', count = ' + count + ')');
observer.next(data);
}, 50);
})
list: [1,2,3,4,5,6,7,8,9]
// test: [1,2,3,4,5,6,7,8,7,6,5,4,3,2,1,0],
// get: (index: number, count: number) => Observable.create(observer => {
// console.log('requested index = ' + index + ', count = ' + count);
// setTimeout(() => {
// let data = [];
// for (let i = index; i <= index + count - 1; i++) {
// data.push({
// id: i,
// text: "item #" + i
// });
// }
// console.log('resolved ' + data.length + ' items (index = ' + index + ', count = ' + count + ')');
// observer.next(data);
// }, 50);
// })
};

constructor() {
Expand Down
14 changes: 10 additions & 4 deletions src/app/ui-scroll-directive/ui-scroll.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<div data-padding-top></div>
<div *ngFor="let item of datasource.list" id="{{item}}">
{{item}}
<ng-template
[ngTemplateOutlet]="templateVariable"
[ngTemplateOutletContext]="{
item: item
}">
</ng-template>
</div>
<!-- <div *ngFor="let item of getItems()" id="{{getItemId(item.$index)}}">
{{item.$index}}
</div> -->
<div *ngFor="let item of getItems()" id="{{getItemId(item.$index)}}">
<div [style.position]="item.invisible ? 'fixed' : null" [style.left]="item.invisible ? '-99999px' : null" >
<ng-template
[ngTemplateOutlet]="templateVariable"
Expand All @@ -12,6 +18,6 @@
}">
</ng-template>
</div>
</div>
</div> -->
<ng-content></ng-content>
<div data-padding-bottom></div>
19 changes: 10 additions & 9 deletions src/app/ui-scroll-directive/ui-scroll.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ export class UiScrollComponent implements OnInit, OnDestroy {

ngOnInit() {
this.datasource = this.uiScrollService.getDatasource();
Elements.initialize(this.elementRef);
Data.initialize(this);
Workflow.initialize(this);
this.onScrollListener = this.renderer.listen(Elements.viewport, 'scroll', (event) =>
debouncedRound(() => Workflow.run(event), 25)
);
console.log(this.templateVariable) // ! undefined
// Elements.initialize(this.elementRef);
// Data.initialize(this);
// Workflow.initialize(this);
// this.onScrollListener = this.renderer.listen(Elements.viewport, 'scroll', (event) =>
// debouncedRound(() => Workflow.run(event), 25)
// );
// Workflow.run(Direction.bottom);
// Workflow.run(Direction.top);
console.log(this);
console.log(this.elementRef.nativeElement.innerHTML.trim());
console.log(this.templateVariable); // Here should be info from app.component.html..?
// console.log(this);
// console.log(this.elementRef.nativeElement.innerHTML.trim());
// console.log(this.templateVariable); // Here should be info from app.component.html..?
}

ngOnDestroy() {
Expand Down

0 comments on commit 99ed60d

Please sign in to comment.