(cm, pos, end, margin)
| 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) { |
no test coverage detected
searching dependent graphs…