How do you know the scroll bar has reached bottom of a page vuejs

    By: Thad Mertz
    3 years ago

    To achieve this we need to setup a eventListener. You can add it inside vue life cycle method, Have a look

    created(){
    
        window.addEventListener('scroll', this.functionToFire);
    
    }
    

    In methods have your function

    methods:{
       functionToFire(){
    
         if($(window).scrollTop() == ($(document).height() - $(window).height()))
         {
             console.log($(window).scrollTop());
         }
      }
    }
    

    You can change "functionToFire" with any function name you prefer. As it is a custom function/Method you can name it anything.

    Once page bottom reaches you will have "scrollTop" value in your "Console.log". There you can call any other method you want.