Better management of up/down scroll

With this change the position and (estimated) size of the tooltip is considered before deciding if a scroll is needed, and how much scrolling to do. This fixes the bug where many times the tooltip is not visible after a scroll.