'Only auto scroll chatbox down if already on bottom

Right now every time ajax is called is scrolling to the bottom, how do I make it scroll only if its only the bottom already but its is anywhere else just remain in that position?

function loadLog(){    
        var oldscrollHeight = 0;         
        $.ajax({  
            url: "log.html",  
            cache: false,  
            success: function(html){          
                $("#chat-content").html(html);     
                var newscrollHeight = $("#chatbox").prop("scrollHeight") - 20; 
                if(newscrollHeight > oldscrollHeight){  
                    $("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal'); 
                }   
    
            },  
        });  
    }  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source