A
A
Analka2020-01-25 00:58:44
Vue.js
Analka, 2020-01-25 00:58:44

Get VueJs scroll coordinates?

how to call the getMessages() method when scrolling up in the message block

<ul class="chat--messages__wrapper" v-if="messages.length > 0">
          <li class="chat--messages__item" v-for="(message,index) in messages">
            <div class="chat--user__image" v-bind:style='{ backgroundImage: `url("/storage/${message.avatar}")` }'></div>
            <div class="chat--user__data">
              <p class="last--massage" v-html="message.replay"></p>
            </div>
          </li>
        </ul>

export default {
            name: "Dialogs",
            data: function () {
                return {
                    messages: [],
                }
            },
            created(){
            },
            watch: {
            },
            computed: {
    
            },
            mounted() {
    
            },
            methods: {
                getMessage(){
                    axios.get('/profile/dialogs/messages',{
                        channels: this.dialogSelect, message:this.message
                    })
                        .then((response) => {
                            this.messages.push(this.email);
                            //this.dialogs = response.data;
                        })
                        .catch(error => {});
                },
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Sertsov, 2020-01-25
@Arge-dev

Create a custom directive, in which bind the function that takes the directive to the object on which you will hang the directive, then you get the scrollTop, and you dance from it.
To create a directive, you can refer to the vue documentation, there is a simple example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question