本机脚本rad-list-view无法检测是向上滑动还是向下滑动项目列表。
通过使用本机脚本滑动事件,一个将获得4个左,右,上和下值,即1,2,4,8。但是滑动操作不适用于rad-list-view。
<lv:RadListView pullToRefresh="true" pullToRefreshInitiated="{{onPullToRefreshInitiated}}"
scrolled="onScrolled" scrollOffset="scrollOffset" scrollStarted="onScrollStarted" scrollEnded="onScrollEnded"
id="id_content" row="1" items="{{ source }}" loaded="onLoaded" backgroundColor="transparent"
itemLoading="onItemLoading" itemTap="onItemTap">
<lv:RadListView.itemTemplate>
<StackLayout orientation="vertical"
backgroundColor="antiquewhite" margin="5" padding="10" borderWidth="1">
<Label fontSize="20" text="{{ name }}"/>
<Label fontSize="14" text="{{ name }}"/>
</StackLayout>
</lv:RadListView.itemTemplate>
<lv:RadListView.listViewLayout>
<lv:ListViewStaggeredLayout scrollDirection="Vertical" spanCount="2"/>
</lv:RadListView.listViewLayout>
<lv:RadListView.pullToRefreshStyle>
<lv:PullToRefreshStyle indicatorColor="red" indicatorBackgroundColor="antiquewhite"/>
</lv:RadListView.pullToRefreshStyle>
</lv:RadListView>
</GridLayout>
如何在radlistview上检测向上或向下滑动事件。
答案 0 :(得分:0)
比较scrollOffset
和scrollStarted
事件之间的scrollEnded
,如果开始位置小于结束位置,则用户已向上滚动,否则向下滚动。
let lastOffset;
export function onScrollStarted(args) {
lastOffset = args.object.getScrollOffset();
}
export function onScrollEnded(args) {
let currentOffset = args.object.getScrollOffset();
console.log(currentOffset < lastOffset ? "Up" : "Down");
lastOffset = currentOffset;
}