Skip to content

Commit 4e47f5c

Browse files
committed
Don't short-circuit out of measures when editor elt is visible
FIX: Fix an issue where some kinds of relayouts could put the editor in a state where it believed it wasn't in window, preventing relayout, though it in fact was. Closes codemirror/dev#1493
1 parent 1118dff commit 4e47f5c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/viewstate.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ function visiblePixelRange(dom: HTMLElement, paddingTop: number): Rect {
3737
top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop)}
3838
}
3939

40+
function inWindow(elt: HTMLElement) {
41+
let rect = elt.getBoundingClientRect(), win = elt.ownerDocument.defaultView || window
42+
return rect.left < win.innerWidth && rect.right > 0 &&
43+
rect.top < win.innerHeight && rect.bottom > 0
44+
}
45+
4046
function fullPixelRange(dom: HTMLElement, paddingTop: number): Rect {
4147
let rect = dom.getBoundingClientRect()
4248
return {left: 0, right: rect.right - rect.left,
@@ -305,7 +311,7 @@ export class ViewState {
305311
this.inView = inView
306312
if (inView) measureContent = true
307313
}
308-
if (!this.inView && !this.scrollTarget) return 0
314+
if (!this.inView && !this.scrollTarget && !inWindow(view.dom)) return 0
309315

310316
let contentWidth = domRect.width
311317
if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {

0 commit comments

Comments
 (0)