(cm, pos, end, margin)
| 3489 | // it actually became visible (as line heights are accurately |
| 3490 | // measured, the position of something may 'drift' during drawing). |
| 3491 | function scrollPosIntoView(cm, pos, end, margin) { |
| 3492 | if (margin == null) margin = 0; |
| 3493 | for (;;) { |
| 3494 | var changed = false, coords = cursorCoords(cm, pos); |
| 3495 | var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); |
| 3496 | var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left), |
| 3497 | Math.min(coords.top, endCoords.top) - margin, |
| 3498 | Math.max(coords.left, endCoords.left), |
| 3499 | Math.max(coords.bottom, endCoords.bottom) + margin); |
| 3500 | var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; |
| 3501 | if (scrollPos.scrollTop != null) { |
| 3502 | setScrollTop(cm, scrollPos.scrollTop); |
| 3503 | if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true; |
| 3504 | } |
| 3505 | if (scrollPos.scrollLeft != null) { |
| 3506 | setScrollLeft(cm, scrollPos.scrollLeft); |
| 3507 | if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true; |
| 3508 | } |
| 3509 | if (!changed) return coords; |
| 3510 | } |
| 3511 | } |
| 3512 | |
| 3513 | // Scroll a given set of coordinates into view (immediately). |
| 3514 | function scrollIntoView(cm, x1, y1, x2, y2) { |
no test coverage detected