Get bottom and right position of an element

Instead of

var bottom = $(window).height() - link.height();
bottom = offset.top - bottom;

Why aren’t you doing

var bottom = $(window).height() - top - link.height();

Edit: Your mistake is that you’re doing

bottom = offset.top - bottom;

instead of

bottom = bottom - offset.top; // or bottom -= offset.top;

Leave a Comment