本地脚本RAD-列表视图不检测是否向上滑动或者向下滑动项目列表。
通过使用本地脚本刷卡事件一会就搞定4个值的左,右,上,下即1,2,4,8。但刷卡动作不工作的RAD-列表视图。
<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刷卡向上或向下的事件。
比较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;
}