FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test(): add scenarios for listview scrolling (#6092) · NativeScript/NativeScript@bdf55d9 · GitHub

Commit bdf55d9

Browse files
authored
test(): add scenarios for listview scrolling (#6092)
1 parent 1fac718 commit bdf55d9

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎apps/app/ui-tests-app/list-view/list-view.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,30 @@ export function onScroll(args: EventData) {
5858
}
5959
scrollToBottom = !scrollToBottom;
6060
}
61+
62+
export function onScrollToIndex(args: EventData) {
63+
let page = (<View>args.object).page;
64+
let gridLayout = page.getViewById<GridLayout>("grid-layout");
65+
for (let i = 0, length = gridLayout.getChildrenCount(); i < length; i++) {
66+
let listView = <ListView>gridLayout.getChildAt(i);
67+
listView.scrollToIndex(50);
68+
}
69+
}
70+
71+
export function onScrollToIndexAnimated(args: EventData) {
72+
let page = (<View>args.object).page;
73+
let gridLayout = page.getViewById<GridLayout>("grid-layout");
74+
for (let i = 0, length = gridLayout.getChildrenCount(); i < length; i++) {
75+
let listView = <ListView>gridLayout.getChildAt(i);
76+
listView.scrollToIndexAnimated(50);
77+
}
78+
}
79+
80+
export function onScrollReset(args: EventData) {
81+
let page = (<View>args.object).page;
82+
let gridLayout = page.getViewById<GridLayout>("grid-layout");
83+
for (let i = 0, length = gridLayout.getChildrenCount(); i < length; i++) {
84+
let listView = <ListView>gridLayout.getChildAt(i);
85+
listView.scrollToIndex(0);
86+
}
87+
}

‎apps/app/ui-tests-app/list-view/list-view.xml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<Page loaded="pageLoaded">
22
<StackLayout>
3-
<Button text="SCROLL" tap="onScroll" height="30"/>
3+
<StackLayout>
4+
<Button text="RESET" tap="onScrollReset" height="30"/>
5+
<Button text="SCROLL" tap="onScroll" height="30"/>
6+
<Button text="SCROLL TO INDEX 50" tap="onScrollToIndex" height="30"/>
7+
<Button text="SCROLL TO INDEX 50 ANIMATED" tap="onScrollToIndexAnimated" height="30"/>
8+
</StackLayout>
49
<GridLayout id="grid-layout" columns="*,*" rows="*,*">
510
<ListView id="lv1" col="0" row="0" items="{{ items }}" itemTemplateSelector="selectItemTemplate">
611
<ListView.itemTemplates>

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL