Fixes #10371: Don't render content widgets if the anchor position is outside the viewport

This commit is contained in:
Alex Dima 2018-04-09 12:23:40 +02:00
parent cc12246b6e
commit def32e0b7c

View file

@ -308,7 +308,8 @@ class Widget {
private _layoutBoxInPage(topLeft: Coordinate, width: number, height: number, ctx: RenderingContext): IBoxLayoutResult { private _layoutBoxInPage(topLeft: Coordinate, width: number, height: number, ctx: RenderingContext): IBoxLayoutResult {
let left0 = topLeft.left - ctx.scrollLeft; let left0 = topLeft.left - ctx.scrollLeft;
if (left0 + width < 0 || left0 > this._contentWidth) { if (left0 < 0 || left0 > this._contentWidth) {
// Don't render if position is scrolled outside viewport
return null; return null;
} }
@ -390,6 +391,7 @@ class Widget {
} }
if (this.allowEditorOverflow) { if (this.allowEditorOverflow) {
console.log(`here i am: ${JSON.stringify(topLeft)}`);
placement = this._layoutBoxInPage(topLeft, this._cachedDomNodeClientWidth, this._cachedDomNodeClientHeight, ctx); placement = this._layoutBoxInPage(topLeft, this._cachedDomNodeClientWidth, this._cachedDomNodeClientHeight, ctx);
} else { } else {
placement = this._layoutBoxInViewport(topLeft, this._cachedDomNodeClientWidth, this._cachedDomNodeClientHeight, ctx); placement = this._layoutBoxInViewport(topLeft, this._cachedDomNodeClientWidth, this._cachedDomNodeClientHeight, ctx);