(cm)
| 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; |
no test coverage detected