-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from bigopon/master
fix(infinite-scroll-next): invoke get more if initial amount of item is small
- Loading branch information
Showing
14 changed files
with
629 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<div class=""> | ||
<div class="d-flex justify-content-around"> | ||
<table class="table table-striped table-sm"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>First Name</th> | ||
<th>Last Name</th> | ||
<th>Action</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr virtual-repeat.for="person of people" infinite-scroll-next.call="push30($scrollContext)"> | ||
<td>${$index}</td> | ||
<td>${person.fname}</td> | ||
<td>${person.lname}</td> | ||
<td> | ||
<button type="button" class="btn btn-link"><i class="far fa-edit"></i></button> | ||
<button type="button" class="btn btn-link"><i class="far fa-trash-alt"></i></button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
interface IScrollContext { | ||
isAtTop: boolean; | ||
isAtBottom: boolean; | ||
topIndex: number; | ||
} | ||
|
||
export interface Person { | ||
fname: string; | ||
lname: string; | ||
} | ||
|
||
const fNames = [ | ||
// tslint:disable-next-line:max-line-length | ||
'Ford', 'Arthur', 'Trillian', 'Sneezy', 'Sleepy', 'Dopey', 'Doc', 'Happy', 'Bashful', 'Grumpy', 'Mufasa', 'Sarabi', 'Simba', 'Nala', 'Kiara', 'Kovu', 'Timon', 'Pumbaa', 'Rafiki', 'Shenzi' | ||
]; | ||
const lNames = [ | ||
// tslint:disable-next-line:max-line-length | ||
'Prefect', 'Dent', 'Astra', 'Adams', 'Baker', 'Clark', 'Davis', 'Evans', 'Frank', 'Ghosh', 'Hills', 'Irwin', 'Jones', 'Klein', 'Lopez', 'Mason', 'Nalty', 'Ochoa', 'Patel', 'Quinn', 'Reily', 'Smith', 'Trott', 'Usman', 'Valdo', 'White', 'Xiang', 'Yakub', 'Zafar' | ||
]; | ||
export class App { | ||
private people: Person[]; | ||
|
||
constructor() { | ||
this.people = [ | ||
{ fname: fNames[0], lname: lNames[0] }, | ||
{ fname: fNames[1], lname: lNames[1] }, | ||
{ fname: fNames[2], lname: lNames[2] } | ||
]; | ||
this.push30(undefined, 0); | ||
} | ||
|
||
public push30(scrollContext?: IScrollContext, count = 30) { | ||
console.log('Issue-102 getting more...'); | ||
// if (scrollContext) { | ||
// console.log('Issue-129 getting more:', JSON.stringify(scrollContext, undefined, 2)); | ||
// } | ||
if (!scrollContext || scrollContext.isAtBottom) { | ||
for (let i = 0; i < count; i++) { | ||
this.people.push({ | ||
fname: fNames[Math.floor(Math.random() * fNames.length)], | ||
lname: lNames[Math.floor(Math.random() * lNames.length)] | ||
}); | ||
} | ||
} | ||
console.log('Population size:', this.people.length); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<div class=""> | ||
<div class="d-flex justify-content-around"> | ||
<table class="table table-striped table-sm"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>First Name</th> | ||
<th>Last Name</th> | ||
<th>Action</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr virtual-repeat.for="person of people" infinite-scroll-next.call="push30($scrollContext)"> | ||
<td>${$index}</td> | ||
<td>${person.fname}</td> | ||
<td>${person.lname}</td> | ||
<td> | ||
<button type="button" class="btn btn-link"><i class="far fa-edit"></i></button> | ||
<button type="button" class="btn btn-link"><i class="far fa-trash-alt"></i></button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
interface IScrollContext { | ||
isAtTop: boolean; | ||
isAtBottom: boolean; | ||
topIndex: number; | ||
} | ||
|
||
export interface Person { | ||
fname: string; | ||
lname: string; | ||
} | ||
|
||
const fNames = [ | ||
// tslint:disable-next-line:max-line-length | ||
'Ford', 'Arthur', 'Trillian', 'Sneezy', 'Sleepy', 'Dopey', 'Doc', 'Happy', 'Bashful', 'Grumpy', 'Mufasa', 'Sarabi', 'Simba', 'Nala', 'Kiara', 'Kovu', 'Timon', 'Pumbaa', 'Rafiki', 'Shenzi' | ||
]; | ||
const lNames = [ | ||
// tslint:disable-next-line:max-line-length | ||
'Prefect', 'Dent', 'Astra', 'Adams', 'Baker', 'Clark', 'Davis', 'Evans', 'Frank', 'Ghosh', 'Hills', 'Irwin', 'Jones', 'Klein', 'Lopez', 'Mason', 'Nalty', 'Ochoa', 'Patel', 'Quinn', 'Reily', 'Smith', 'Trott', 'Usman', 'Valdo', 'White', 'Xiang', 'Yakub', 'Zafar' | ||
]; | ||
export class App { | ||
private people: Person[]; | ||
|
||
constructor() { | ||
this.people = [ | ||
{ fname: fNames[0], lname: lNames[0] }, | ||
{ fname: fNames[1], lname: lNames[1] }, | ||
{ fname: fNames[2], lname: lNames[2] } | ||
]; | ||
this.push30(undefined, 5); | ||
} | ||
|
||
public push30(scrollContext?: IScrollContext, count = 30) { | ||
console.log('Issue-129 getting more...'); | ||
// if (scrollContext) { | ||
// console.log('Issue-129 getting more:', JSON.stringify(scrollContext, undefined, 2)); | ||
// } | ||
if (!scrollContext || scrollContext.isAtBottom) { | ||
for (let i = 0; i < count; i++) { | ||
this.people.push({ | ||
fname: fNames[Math.floor(Math.random() * fNames.length)], | ||
lname: lNames[Math.floor(Math.random() * lNames.length)] | ||
}); | ||
} | ||
} | ||
console.log('Population size:', this.people.length); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,7 @@ export { | |
VirtualRepeat, | ||
InfiniteScrollNext | ||
}; | ||
|
||
export { | ||
IScrollNextScrollContext | ||
} from './interfaces'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.