MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / scrollCursorIntoView

Function scrollCursorIntoView

static/js/codemirror/codemirror.js:2407–2423  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

2405 // SCROLLING
2406
2407 function scrollCursorIntoView(cm) {
2408 var coords = scrollPosIntoView(cm, cm.doc.sel.head);
2409 if (!cm.state.focused) return;
2410 var display = cm.display, box = getRect(display.sizer), doScroll = null;
2411 if (coords.top + box.top < 0) doScroll = true;
2412 else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
2413 if (doScroll != null && !phantom) {
2414 var hidden = display.cursor.style.display == "none";
2415 if (hidden) {
2416 display.cursor.style.display = "";
2417 display.cursor.style.left = coords.left + "px";
2418 display.cursor.style.top = (coords.top - display.viewOffset) + "px";
2419 }
2420 display.cursor.scrollIntoView(doScroll);
2421 if (hidden) display.cursor.style.display = "none";
2422 }
2423 }
2424
2425 function scrollPosIntoView(cm, pos) {
2426 for (;;) {

Callers 1

endOperationFunction · 0.85

Calls 2

scrollPosIntoViewFunction · 0.85
getRectFunction · 0.85

Tested by

no test coverage detected