-
-
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 #153 from jorgenskogas/find-anchestor-scroller-item
Walk up the DOM tree and determine what element will be scroller
- Loading branch information
Showing
5 changed files
with
119 additions
and
9 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
sample/sample-v-ui-app/src/non-issues/scroller-not-first-parent-div/sub-app.html
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,61 @@ | ||
<template> | ||
<div class="scroller"> | ||
<div class="grid-force-size"> | ||
<div class="d-flex grid-header"> | ||
<div class="p-2 grid-column-index" style="width: 50px;">#</div> | ||
<div class="p-2" style="width: 200px;">First Name</div> | ||
<div class="p-2" style="width: 200px;">Last Name</div> | ||
<div class="p-2 flex-fill">Action</div> | ||
</div> | ||
<div | ||
virtual-repeat.for="person of people" | ||
infinite-scroll-next.call="push30($scrollContext)" | ||
class="d-flex grid-row ${$even ? 'grid-row-even' : 'grid-row-odd'}"> | ||
<div class="p-2 grid-column-index" style="width: 50px;">${$index}</div> | ||
<div class="p-2" style="width: 200px;">${person.fname}</div> | ||
<div class="p-2" style="width: 200px;">${person.lname}</div> | ||
<div class="flex-fill"> | ||
<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> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<style> | ||
.scroller { | ||
position: relative; | ||
height: 500px; | ||
width: 300px; | ||
overflow: scroll; | ||
} | ||
.grid-force-size { | ||
border-right: 3px solid #ff00ff; | ||
border-bottom: 3px solid #ff00ff; | ||
width: 600px; | ||
} | ||
.grid-header { | ||
position: sticky; | ||
top: 0px; | ||
background-color: #f0f0f0; | ||
border-top: 3px solid #ff00ff; | ||
z-index: 2; | ||
} | ||
.grid-row-even { | ||
background-color: #fff; | ||
} | ||
.grid-row-odd { | ||
background-color: #f1a3f1; | ||
} | ||
.grid-column-index { | ||
position: sticky; | ||
left: 0px; | ||
border-left: 3px solid #ff00ff; | ||
z-index: 1; | ||
background-color: aqua; | ||
text-align: center; | ||
} | ||
.grid-header .grid-column-index { | ||
background-color: #f0f0f0; | ||
} | ||
</style> | ||
</template> |
43 changes: 43 additions & 0 deletions
43
sample/sample-v-ui-app/src/non-issues/scroller-not-first-parent-div/sub-app.ts
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,43 @@ | ||
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', 'Jørgen', '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 PromiseGetMoreApp { | ||
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 async push30(scrollContext?: IScrollContext, count = 30) { | ||
if (this.people.length < 200 && (!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
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