微信小程序,滚动标记消息已读

记录。

滚动的时候去找dom,然后看top是否小于某一个高度(屏幕可用高度)为已读,进行标记。

 

1
2
3
4
<scroll-view scroll-y scroll-into-view="{{toItemView}}" bindscroll="scrolltoupper">
<view wx:for="{{10}}"  id="ItemView{{index}}">
</view>  
</scroll-view>

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 获取滚动条当前位置
  scrolltoupper: function (e) {
    let that =this;
    var Lists = this.createSelectorQuery().selectAll(".WaitingTag").boundingClientRect();
    Lists.exec(function (res) {
      res[0].forEach((item,index) => {
        //检查是否已读,top在小于屏幕可用范围内为已读
        if(item.top<=(that.data.windowHeight-that.data.CustomBar-200))//一个框框最小400rpx
        {
          if(that.data.readList.indexOf(item.id)<0){
            that.data.readList.push(item.id);
            var list=that.data.readList;
            that.setData({
              readList:list
            })<br>        //设置已读操作。。。<br>        
          }
        }
      });
    })
  },

  

posted @   小杨观世界  阅读(390)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示