Answer the question
In order to leave comments, you need to log in
Vue js scroll event?
there is a list of dialogues
<div class="contact-card" @click.prevent="selectUser(dialog.id,dialog.user,index)">
<div class="contact-card__data">
<div class="contact-card__data--text">
<p class="username">{{dialog.fullname}}</p>
<p class="last--massage" v-html="dialog.message"></p>
</div>
</div>
</div>
selectUser(id,user,x,avatar, fullname){
this.dialogSelect = id;
this.userSelect.id = user;
this.dialogIndex = x;
axios.post('/profile/dialogs/messages',{
dialog_id: id,
offset: this.offset,
limit: this.limit
})
.then((response) => {
this.messages = response.data.messages;
setTimeout(() => {
$('.chat--messages__wrapper').scrollTop($('.chat--messages__wrapper').prop('scrollHeight') + 25);
}, 500)
})
.catch(error => {});
},
<ul class="chat--messages__wrapper" v-if="messages.length > 0" >
<li class="chat--messages__item" v-for="(message,index) in messages">
<p class="last--massage" v-html="message.replay"></p>
</div>
</li>
</ul>
created () {
window.addEventListener('scroll', this.onScroll);
},
destroyed () {
window.removeEventListener('scroll', this.onScroll);
},
onScroll(event){
console.log(window.scrollY);
console.log(window.scrollX);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question