(cm, coords)
| 4581 | // If an editor sits on the top or bottom of the window, partially |
| 4582 | // scrolled out of view, this ensures that the cursor is visible. |
| 4583 | function maybeScrollWindow(cm, coords) { |
| 4584 | if (signalDOMEvent(cm, "scrollCursorIntoView")) return; |
| 4585 | |
| 4586 | var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; |
| 4587 | if (coords.top + box.top < 0) doScroll = true; |
| 4588 | else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false; |
| 4589 | if (doScroll != null && !phantom) { |
| 4590 | var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " + |
| 4591 | (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " + |
| 4592 | (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " + |
| 4593 | coords.left + "px; width: 2px;"); |
| 4594 | cm.display.lineSpace.appendChild(scrollNode); |
| 4595 | scrollNode.scrollIntoView(doScroll); |
| 4596 | cm.display.lineSpace.removeChild(scrollNode); |
| 4597 | } |
| 4598 | } |
| 4599 | |
| 4600 | // Scroll a given position into view (immediately), verifying that |
| 4601 | // it actually became visible (as line heights are accurately |
no test coverage detected