mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
test(): add scenarios for listview scrolling (#6092)
This commit is contained in:
@ -58,3 +58,30 @@ export function onScroll(args: EventData) {
|
||||
}
|
||||
scrollToBottom = !scrollToBottom;
|
||||
}
|
||||
|
||||
export function onScrollToIndex(args: EventData) {
|
||||
let page = (<View>args.object).page;
|
||||
let gridLayout = page.getViewById<GridLayout>("grid-layout");
|
||||
for (let i = 0, length = gridLayout.getChildrenCount(); i < length; i++) {
|
||||
let listView = <ListView>gridLayout.getChildAt(i);
|
||||
listView.scrollToIndex(50);
|
||||
}
|
||||
}
|
||||
|
||||
export function onScrollToIndexAnimated(args: EventData) {
|
||||
let page = (<View>args.object).page;
|
||||
let gridLayout = page.getViewById<GridLayout>("grid-layout");
|
||||
for (let i = 0, length = gridLayout.getChildrenCount(); i < length; i++) {
|
||||
let listView = <ListView>gridLayout.getChildAt(i);
|
||||
listView.scrollToIndexAnimated(50);
|
||||
}
|
||||
}
|
||||
|
||||
export function onScrollReset(args: EventData) {
|
||||
let page = (<View>args.object).page;
|
||||
let gridLayout = page.getViewById<GridLayout>("grid-layout");
|
||||
for (let i = 0, length = gridLayout.getChildrenCount(); i < length; i++) {
|
||||
let listView = <ListView>gridLayout.getChildAt(i);
|
||||
listView.scrollToIndex(0);
|
||||
}
|
||||
}
|
@ -1,6 +1,11 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<StackLayout>
|
||||
<Button text="SCROLL" tap="onScroll" height="30"/>
|
||||
<StackLayout>
|
||||
<Button text="RESET" tap="onScrollReset" height="30"/>
|
||||
<Button text="SCROLL" tap="onScroll" height="30"/>
|
||||
<Button text="SCROLL TO INDEX 50" tap="onScrollToIndex" height="30"/>
|
||||
<Button text="SCROLL TO INDEX 50 ANIMATED" tap="onScrollToIndexAnimated" height="30"/>
|
||||
</StackLayout>
|
||||
<GridLayout id="grid-layout" columns="*,*" rows="*,*">
|
||||
<ListView id="lv1" col="0" row="0" items="{{ items }}" itemTemplateSelector="selectItemTemplate">
|
||||
<ListView.itemTemplates>
|
||||
|
Reference in New Issue
Block a user