MCPcopy Create free account
hub / github.com/sql-js/sql.js / scrollPosIntoView

Function scrollPosIntoView

GUI/codemirror/lib/codemirror.js:3531–3551  ·  view source on GitHub ↗
(cm, pos, end, margin)

Source from the content-addressed store, hash-verified

3529 // it actually became visible (as line heights are accurately
3530 // measured, the position of something may 'drift' during drawing).
3531 function scrollPosIntoView(cm, pos, end, margin) {
3532 if (margin == null) margin = 0;
3533 for (;;) {
3534 var changed = false, coords = cursorCoords(cm, pos);
3535 var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
3536 var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
3537 Math.min(coords.top, endCoords.top) - margin,
3538 Math.max(coords.left, endCoords.left),
3539 Math.max(coords.bottom, endCoords.bottom) + margin);
3540 var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
3541 if (scrollPos.scrollTop != null) {
3542 setScrollTop(cm, scrollPos.scrollTop);
3543 if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
3544 }
3545 if (scrollPos.scrollLeft != null) {
3546 setScrollLeft(cm, scrollPos.scrollLeft);
3547 if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
3548 }
3549 if (!changed) return coords;
3550 }
3551 }
3552
3553 // Scroll a given set of coordinates into view (immediately).
3554 function scrollIntoView(cm, x1, y1, x2, y2) {

Callers 1

endOperationFunction · 0.85

Calls 4

cursorCoordsFunction · 0.85
calculateScrollPosFunction · 0.85
setScrollTopFunction · 0.85
setScrollLeftFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…