fix bug when tooltips are near the edge of the page