MCPcopy
hub / github.com/witheve/Eve / maybeScrollWindow

Function maybeScrollWindow

src/codemirror.js:4606–4621  ·  view source on GitHub ↗
(cm, coords)

Source from the content-addressed store, hash-verified

4604 // If an editor sits on the top or bottom of the window, partially
4605 // scrolled out of view, this ensures that the cursor is visible.
4606 function maybeScrollWindow(cm, coords) {
4607 if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
4608
4609 var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
4610 if (coords.top + box.top < 0) doScroll = true;
4611 else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
4612 if (doScroll != null && !phantom) {
4613 var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
4614 (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
4615 (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
4616 coords.left + "px; width: 2px;");
4617 cm.display.lineSpace.appendChild(scrollNode);
4618 scrollNode.scrollIntoView(doScroll);
4619 cm.display.lineSpace.removeChild(scrollNode);
4620 }
4621 }
4622
4623 // Scroll a given position into view (immediately), verifying that
4624 // it actually became visible (as line heights are accurately

Callers 1

endOperation_finishFunction · 0.85

Calls 5

signalDOMEventFunction · 0.85
eltFunction · 0.85
paddingTopFunction · 0.85
scrollGapFunction · 0.85
scrollIntoViewMethod · 0.80

Tested by

no test coverage detected