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