(cm, rect)
| 3408 | // If an editor sits on the top or bottom of the window, partially |
| 3409 | // scrolled out of view, this ensures that the cursor is visible. |
| 3410 | function maybeScrollWindow(cm, rect) { |
| 3411 | if (signalDOMEvent(cm, "scrollCursorIntoView")) { return } |
| 3412 | |
| 3413 | var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; |
| 3414 | if (rect.top + box.top < 0) { doScroll = true; } |
| 3415 | else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; } |
| 3416 | if (doScroll != null && !phantom) { |
| 3417 | var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;")); |
| 3418 | cm.display.lineSpace.appendChild(scrollNode); |
| 3419 | scrollNode.scrollIntoView(doScroll); |
| 3420 | cm.display.lineSpace.removeChild(scrollNode); |
| 3421 | } |
| 3422 | } |
| 3423 | |
| 3424 | // Scroll a given position into view (immediately), verifying that |
| 3425 | // it actually became visible (as line heights are accurately |
no test coverage detected