Daniil464,
mousemove: function(e){
let all = jQuery(window).height();
let height = jQuery('#hint').outerHeight(true) + 30;
let offset = all - (e.clientY + height);
let pagetop = e.pageY;
if (offset < 0) pagetop = e.pageY + offset;
hint.css({top: pagetop, left: e.pageX});
}