MCPcopy Create free account
hub / github.com/TruthHun/BookStack / maybeScrollWindow

Function maybeScrollWindow

static/editor.md/lib/codemirror/lib/codemirror.js:4404–4419  ·  view source on GitHub ↗
(cm, coords)

Source from the content-addressed store, hash-verified

4402 // If an editor sits on the top or bottom of the window, partially
4403 // scrolled out of view, this ensures that the cursor is visible.
4404 function maybeScrollWindow(cm, coords) {
4405 if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
4406
4407 var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
4408 if (coords.top + box.top < 0) doScroll = true;
4409 else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
4410 if (doScroll != null && !phantom) {
4411 var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
4412 (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
4413 (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
4414 coords.left + "px; width: 2px;");
4415 cm.display.lineSpace.appendChild(scrollNode);
4416 scrollNode.scrollIntoView(doScroll);
4417 cm.display.lineSpace.removeChild(scrollNode);
4418 }
4419 }
4420
4421 // Scroll a given position into view (immediately), verifying that
4422 // it actually became visible (as line heights are accurately

Callers 1

endOperation_finishFunction · 0.70

Calls 4

signalDOMEventFunction · 0.70
eltFunction · 0.70
paddingTopFunction · 0.70
scrollGapFunction · 0.70

Tested by

no test coverage detected