PullUpLoadMore.ets
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import PageModel from '../viewmodel/PageModel';
import { RefreshConstants as Const } from './RefreshConstants';
import PageHelper from '../viewmodel/PageHelper';
export function touchMoveLoadMore(model: PageModel, event: TouchEvent) {
// list size +1
if (model.endIndex >= model.compList.totalCount()-3 && model.endIndex <= model.compList.totalCount()) {
// model.offsetY = event.touches[0].y - model.downY;
// if (Math.abs(model.offsetY) > vp2px(model.pullUpLoadHeight) / 2) {
// model.isCanLoadMore = true;
// model.isVisiblePullUpLoad = true;
// model.offsetY = -vp2px(model.pullUpLoadHeight) + model.offsetY * Const.Y_OFF_SET_COEFFICIENT;
// }
// 不用分页动画,直接预加载
model.isCanLoadMore = true;
model.isVisiblePullUpLoad = true;
touchUpLoadMore(model);
}
}
export function touchUpLoadMore(model: PageModel) {
let self: PageModel = model;
animateTo({
duration: Const.ANIMATION_DURATION,
}, () => {
self.offsetY = 0;
})
if ((self.isCanLoadMore === true) && (self.hasMore === true) && (self.isLoading === false)) {
self.isLoading = true;
setTimeout(() => {
closeLoadMore(model);
PageHelper.loadMore(self)
}, Const.DELAY_TIME);
} else {
closeLoadMore(self);
}
}
export function closeLoadMore(model: PageModel) {
model.isCanLoadMore = false;
model.isLoading = false;
model.isVisiblePullUpLoad = false;
}