Add a check for negative bounds when translating the overlay

This commit is contained in:
Ben Ogle
2014-11-12 11:50:22 -08:00
parent 12b9f232c2
commit eae80ca46d
2 changed files with 55 additions and 2 deletions

View File

@@ -36,10 +36,12 @@ class OverlayManager
itemHeight = item.offsetHeight
left = pixelPosition.left
left -= itemWidth if left + itemWidth - editor.getScrollLeft() > editor.getWidth()
if left + itemWidth - editor.getScrollLeft() > editor.getWidth() and left - itemWidth >= editor.getScrollLeft()
left -= itemWidth
top = pixelPosition.top + lineHeightInPixels
top -= itemHeight + lineHeightInPixels if top + itemHeight - editor.getScrollTop() > editor.getHeight()
if top + itemHeight - editor.getScrollTop() > editor.getHeight() and top - itemHeight - lineHeightInPixels >= editor.getScrollTop()
top -= itemHeight + lineHeightInPixels
overlay.style.top = top + 'px'
overlay.style.left = left + 'px'