MCPcopy
hub / github.com/csev/py4e / maybeScrollWindow

Function maybeScrollWindow

tools/pythonauto/static/codemirrorepl/codemirror.js:3473–3486  ·  view source on GitHub ↗
(cm, coords)

Source from the content-addressed store, hash-verified

3471 // If an editor sits on the top or bottom of the window, partially
3472 // scrolled out of view, this ensures that the cursor is visible.
3473 function maybeScrollWindow(cm, coords) {
3474 var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
3475 if (coords.top + box.top < 0) doScroll = true;
3476 else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
3477 if (doScroll != null && !phantom) {
3478 var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
3479 (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
3480 (coords.bottom - coords.top + scrollerCutOff) + "px; left: " +
3481 coords.left + "px; width: 2px;");
3482 cm.display.lineSpace.appendChild(scrollNode);
3483 scrollNode.scrollIntoView(doScroll);
3484 cm.display.lineSpace.removeChild(scrollNode);
3485 }
3486 }
3487
3488 // Scroll a given position into view (immediately), verifying that
3489 // it actually became visible (as line heights are accurately

Callers 1

endOperationFunction · 0.85

Calls 4

eltFunction · 0.70
paddingTopFunction · 0.70
appendChildMethod · 0.45
removeChildMethod · 0.45

Tested by

no test coverage detected