1、是否滚动到底部
isScrollBottom() {
// 是否滚动到了底部
this.box = this.$refs.chatListWrapper
var clientHeight = this.box.clientHeight
var scrollTop = this.box.scrollTop
var scrollHeight = this.box.scrollHeight
if (scrollTop + clientHeight == scrollHeight) {
this.$store.dispatch('setBottomBtn', false, { root: true }) // 隐藏直达最新消息按钮
this.isBottom = true
this.isTop = false
} else {
this.$store.dispatch('setBottomBtn', true, { root: true }) // 显示直达最新消息按钮
this.isTop = false
this.isBottom = false
if (scrollTop == 0) {
this.isTop = true
}
}
},
2、scroll滚动方向判断
getDirection() {
// scroll滚动方向~~~~
this.box = this.$refs.chatListWrapper
var scrollTop = this.box.scrollTop
var scroll = scrollTop - this.initTop
this.initTop = scrollTop
let dir = 'down'
if (scroll < 0) {
dir = 'up'
} else {
dir = 'down'
}
return dir
},
3、滚动节流
1)、在滚动的dom上绑定scroll事件,监听滚动
2)、data中定义:fnScroll: () => {}, 初始值
3)、mounted中给fnScroll函数赋值,_.throttle实现滚动节流
this.fnScroll = _.throttle(() => {
}, 500)
4、获取滚动可视区域内dom:
实现注意:判断当前元素是否在可视区域内,若在则存到isSeeDomArr中,然后循环isSeeDomArr数组,拿到当前可视区域内的最后一个dom,再去判断是否更新对应的咨询轨迹。
不要滚动时就去更新,这样会造成不停请求更新,最后一次请求可能无效,造成数据的错乱
sendRead() {
const chatLi = document
.getElementById('chat_list_wrapper')
.getElementsByTagName('li')
var container = this.$refs.chatListWrapper
var swHeight = container.clientHeight
const scrollTop = container.scrollTop
const aa = swHeight + scrollTop
let isSeeDomArr = []
for (let j = 0; j < chatLi.length; j++) {
if (scrollTop < chatLi[j].offsetTop && chatLi[j].offsetTop < aa) {
isSeeDomArr.push(chatLi[j]) //将可视区域内所有dom存储到isSeeDomArr
}
}
if (isSeeDomArr.length) {
// 非 ceo接诊台更新消息的已读状态
if (this.$route.path.indexOf('diagnose/ceo') === -1) {
for (let m = 0; m < isSeeDomArr.length; m++) {
const isSelfSend = isSeeDomArr[m].getAttribute('isSelfSend')
const msgStatus = isSeeDomArr[m].getAttribute('msgStatus')
const msgType = isSeeDomArr[m].getAttribute('msgType')
if (!isSelfSend && !msgStatus && msgType !== 'notice') {
const _id = isSeeDomArr[m].getAttribute('id')
this.sendReadApi(_id)
}
}
}
// 更新聊天对应的咨询轨迹
this.setCurrentFdAsk(
isSeeDomArr[isSeeDomArr.length - 1].getAttribute('fdAsk')
)
}
},
the end:滚动加载这些判断前前后后改了好多次,这次终于感觉逻辑比较清晰了,也算对自己有个交代。。。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
