+7
-7
@@ -46,13 +46,13 @@ export class Viewport {
|
|||||||
private refresh(charSize?: ClientRect): void {
|
private refresh(charSize?: ClientRect): void {
|
||||||
var size = charSize || this.charMeasureElement.getBoundingClientRect();
|
var size = charSize || this.charMeasureElement.getBoundingClientRect();
|
||||||
if (size.height > 0) {
|
if (size.height > 0) {
|
||||||
var rowHeightChanged = size.height !== this.currentRowHeight;
|
const rowHeightChanged = size.height !== this.currentRowHeight;
|
||||||
if (rowHeightChanged) {
|
if (rowHeightChanged) {
|
||||||
this.currentRowHeight = size.height;
|
this.currentRowHeight = size.height;
|
||||||
this.viewportElement.style.lineHeight = size.height + 'px';
|
this.viewportElement.style.lineHeight = size.height + 'px';
|
||||||
this.terminal.rowContainer.style.lineHeight = size.height + 'px';
|
this.terminal.rowContainer.style.lineHeight = size.height + 'px';
|
||||||
}
|
}
|
||||||
var viewportHeightChanged = this.lastRecordedViewportHeight !== this.terminal.rows;
|
const viewportHeightChanged = this.lastRecordedViewportHeight !== this.terminal.rows;
|
||||||
if (rowHeightChanged || viewportHeightChanged) {
|
if (rowHeightChanged || viewportHeightChanged) {
|
||||||
this.lastRecordedViewportHeight = this.terminal.rows;
|
this.lastRecordedViewportHeight = this.terminal.rows;
|
||||||
this.viewportElement.style.height = size.height * this.terminal.rows + 'px';
|
this.viewportElement.style.height = size.height * this.terminal.rows + 'px';
|
||||||
@@ -74,14 +74,14 @@ export class Viewport {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
} else {
|
} else {
|
||||||
// If size has changed, refresh viewport
|
// If size has changed, refresh viewport
|
||||||
var size = this.charMeasureElement.getBoundingClientRect();
|
const size = this.charMeasureElement.getBoundingClientRect();
|
||||||
if (size.height !== this.currentRowHeight) {
|
if (size.height !== this.currentRowHeight) {
|
||||||
this.refresh(size);
|
this.refresh(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync scrollTop
|
// Sync scrollTop
|
||||||
var scrollTop = this.terminal.ydisp * this.currentRowHeight;
|
const scrollTop = this.terminal.ydisp * this.currentRowHeight;
|
||||||
if (this.viewportElement.scrollTop !== scrollTop) {
|
if (this.viewportElement.scrollTop !== scrollTop) {
|
||||||
this.viewportElement.scrollTop = scrollTop;
|
this.viewportElement.scrollTop = scrollTop;
|
||||||
}
|
}
|
||||||
@@ -93,8 +93,8 @@ export class Viewport {
|
|||||||
* @param ev The scroll event.
|
* @param ev The scroll event.
|
||||||
*/
|
*/
|
||||||
private onScroll(ev: Event) {
|
private onScroll(ev: Event) {
|
||||||
var newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
|
const newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
|
||||||
var diff = newRow - this.terminal.ydisp;
|
const diff = newRow - this.terminal.ydisp;
|
||||||
this.terminal.scrollDisp(diff, true);
|
this.terminal.scrollDisp(diff, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ export class Viewport {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Fallback to WheelEvent.DOM_DELTA_PIXEL
|
// Fallback to WheelEvent.DOM_DELTA_PIXEL
|
||||||
var multiplier = 1;
|
let multiplier = 1;
|
||||||
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
||||||
multiplier = this.currentRowHeight;
|
multiplier = this.currentRowHeight;
|
||||||
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user