MCPcopy Index your code
hub / github.com/csev/py4e / scrollCursorIntoView

Function scrollCursorIntoView

tools/pythonauto/static/codemirror/codemirror.js:2678–2693  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

2676 // SCROLLING
2677
2678 function scrollCursorIntoView(cm) {
2679 var coords = scrollPosIntoView(cm, cm.doc.sel.head, null, cm.options.cursorScrollMargin);
2680 if (!cm.state.focused) return;
2681 var display = cm.display, box = getRect(display.sizer), doScroll = null;
2682 if (coords.top + box.top < 0) doScroll = true;
2683 else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
2684 if (doScroll != null && !phantom) {
2685 var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
2686 (coords.top - display.viewOffset) + "px; height: " +
2687 (coords.bottom - coords.top + scrollerCutOff) + "px; left: " +
2688 coords.left + "px; width: 2px;");
2689 cm.display.lineSpace.appendChild(scrollNode);
2690 scrollNode.scrollIntoView(doScroll);
2691 cm.display.lineSpace.removeChild(scrollNode);
2692 }
2693 }
2694
2695 function scrollPosIntoView(cm, pos, end, margin) {
2696 if (margin == null) margin = 0;

Callers 1

endOperationFunction · 0.70

Calls 5

getRectFunction · 0.85
scrollPosIntoViewFunction · 0.70
eltFunction · 0.70
appendChildMethod · 0.45
removeChildMethod · 0.45

Tested by

no test coverage detected