微信小程序 实现listview带字母滑动
更新时间:2017年05月12日 15:15:16 作者:kingrome2017
这篇文章主要介绍了微信小程序 实现listview带字母滑动的相关资料,需要的朋友可以参考下
微信小程序 实现listview带字母滑动
wxml
<!--字母滑动-->
<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>
<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
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
});
},
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关文章
iOS中关于Swift UICollectionView横向分页的问题
这篇文章通过图文并茂的形式给大家介绍UICollectionView横向分页的问题,非常不错,具有参考借鉴价值,需要的的朋友参考下吧2017-05-05
实例讲解iOS音乐播放器DOUAudioStreamer用法
本篇文章给大家通过实例讲解了iOS音乐播放器DOUAudioStreamer用法以及分享了实例代码,一起学习参考下吧。2017-12-12
Flutter Widgets粘合剂CustomScrollView NestedScrollVie
这篇文章主要为大家介绍了Flutter Widgets粘合剂CustomScrollView NestedScrollView滚动控件示例详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-11-11


最新评论