From 6439aca1d847113f56aeb2ace8b83eee14d27513 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 27 Jan 2018 15:00:19 -0800 Subject: [PATCH] Refresh dimensions of only a single row --- src/AccessibilityManager.ts | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/AccessibilityManager.ts b/src/AccessibilityManager.ts index 969a9837..fdcf4887 100644 --- a/src/AccessibilityManager.ts +++ b/src/AccessibilityManager.ts @@ -139,11 +139,15 @@ export class AccessibilityManager implements IDisposable { // Add new element to array/DOM if (position === BoundaryPosition.Top) { - this._rowElements.unshift(this._createAccessibilityTreeNode()); - this._rowContainer.insertAdjacentElement('afterbegin', this._rowElements[0]); + const newElement = this._createAccessibilityTreeNode(); + this._rowElements.unshift(newElement); + this._refreshRowDimensions(newElement); + this._rowContainer.insertAdjacentElement('afterbegin', newElement); } else { - this._rowElements.push(this._createAccessibilityTreeNode()); - this._rowContainer.appendChild(this._rowElements[this._rowElements.length - 1]); + const newElement = this._createAccessibilityTreeNode(); + this._rowElements.push(newElement); + this._refreshRowDimensions(newElement); + this._rowContainer.appendChild(newElement); } // Add listeners to new boundary elements @@ -153,9 +157,6 @@ export class AccessibilityManager implements IDisposable { // Scroll up this._terminal.scrollLines(position === BoundaryPosition.Top ? -1 : 1); - // TODO: Only refresh only a single row - this._refreshRowsDimensions(); - // Focus new boundary before element this._rowElements[position === BoundaryPosition.Top ? 1 : this._rowElements.length - 2].focus(); @@ -266,22 +267,17 @@ export class AccessibilityManager implements IDisposable { // TODO: Clean up } - public rotateRows(): void { - // this._rowContainer.removeChild(this._rowElements.shift()); - // const newRowIndex = this._rowElements.length; - // this._rowElements[newRowIndex] = this._createAccessibilityTreeNode(); - // this._rowContainer.appendChild(this._rowElements[newRowIndex]); - // this._refreshRowsDimensions(); - } - private _refreshRowsDimensions(): void { const buffer: IBuffer = (this._terminal.buffer); - const dimensions = this._terminal.renderer.dimensions; for (let i = 0; i < this._terminal.rows; i++) { - this._rowElements[i].style.height = `${dimensions.actualCellHeight}px`; + this._refreshRowDimensions(this._rowElements[i]); } } + private _refreshRowDimensions(element: HTMLElement): void { + element.style.height = `${this._terminal.renderer.dimensions.actualCellHeight}px`; + } + public announce(text: string): void { this._clearLiveRegion(); this._liveRegion.textContent = text;