微信小程序 实现listview带字母滑动
wxml
1
2
3
4
5
6
7
8
9
10
|
<!--字母滑动-->
< view class = "letter-position" wx:if = "{{filterType == 'name'}}" hidden = "{{letterShow?'true':''}}" style = "z-index:{{Zindex}}" catchtouchstart = "handlerAlphaTap" catchtouchmove = "handlerMove" catchtouchend = "handlerEnd" >
< image class = "no-stars star-icon" data-loc = "star" src = "../img/no-stars.png" ></ image >
< text class = "letter" wx:for = "{{groups}}" wx:for-item = "group" data-loc = "{{group.id}}" wx:key = "L_{{group.id}}" >
{{group.id}}
</ text >
< text class = "letter no-letter" >
#
</ text >
</ view >
|
1
|
<scroll-view scroll-into-view= "{{locationTo}}" bindscrolltolower= "onscrollLower" scroll-y= "{{trues}}" style= "height: {{clientHeihgt?clientHeihgt+'px':'auto'}}" bindscroll= "scroll" scroll-top= "{{scrollTop}}" hidden= "{{favoriteCards.length==0 && starCards.length ==0}}" >
|
js
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
46
47
48
|
handlerAlphaTap(e) {
var ap = e.target.dataset.loc; //字母
this .setData({
locationTo: ap
});
var list = this .data.groups;
this .offsetTop = ( this .data.clientHeihgt - list.length * 16) / 2;
},
handlerMove(e) {
var _this = this ;
var list = this .data.groups;
var moveY = e.touches[0].clientY;
var rY = moveY - this .offsetTop;
if (rY >= 0) {
var index = Math.ceil((rY - 16) / 16);
if (0 <= index && index < list.length) {
_this.setData({
locationTo: list[index].id,
nonwApID: list[index].id,
fly: false ,
//nonwAp: list[index]
});
// _this.setData({
// nonwApID:_this.data.nonwAp.id
// });
}
}
},
handlerEnd(e) {
// try{
this .setData({
nonwApID: '' ,
fly: true ,
// locationTo:this.data.nonwAp.id
});
// }catch(e){
// }
var _this = this ;
this .setData({
scoTTTTp: e.currentTarget.dataset.scrollTop
});
},
|
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
原文链接:http://blog.csdn.net/kingrome2017/article/details/71330867