Path: blob/main/replay/backend/overlays/CommandOverlay.ts
1030 views
import BaseOverlay from '~backend/overlays/BaseOverlay';1import IRectangle from '~shared/interfaces/IRectangle';23const width = 416;4const containerOffset = width / 5;5export default class CommandOverlay extends BaseOverlay {6public static width = width;7constructor() {8super({9name: 'command-overlay',10maxHeight: 250,11calcBounds(bounds: IRectangle) {12let x = bounds.x - containerOffset;13if (x + width > bounds.right + 50) {14x = bounds.right + 50 - width;15}16if (bounds.left !== undefined) {17if (x < bounds.left - 50) {18x = bounds.left - 50;19}20}2122bounds.height = Math.max(this.lastHeight, 100) + 28;23bounds.y -= bounds.height;2425return {26width,27height: bounds.height,28x,29y: bounds.y,30};31},32onWindowBoundsUpdate: () => {33this.hide();34},35});36}3738protected async adjustHeight(): Promise<void> {39const isFirstDraw = this.lastHeight === 0;40await super.adjustHeight();41if (this.hasNewHeight && isFirstDraw) this.rearrange(this.browserView.getBounds());42}43}444546