view.js
1.04 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
45
import {
View
} from 'js/yoho-mvc';
class TabView extends View {
constructor() {
super('.tab');
this.end = false;
this.on('touchend touchcancel', 'span', this.tabClick.bind(this));
}
tabClick(e) {
let $this = $(e.currentTarget);
if (!$this.hasClass('active')) {
let $index = $this.index();
$this.addClass('active').siblings('span').removeClass('active');
$('.tab-item:eq(' + $index + ')').removeClass('hide').siblings('.tab-item').addClass('hide');
window.rePosFooter();
}
}
}
class GetContent extends View {
constructor() {
super('.grade-new-c');
// srcoll to load more
$(window).scroll(() => {
window.requestAnimationFrame(this.scrollHandler.bind(this));
});
}
scrollHandler() {
if (($(window).scrollTop() + $(window).height() >= $(document).height()) && $('.ul-detail').length > 0) {
this.emit('search');
}
}
}
export {
TabView,
GetContent
};