-
Notifications
You must be signed in to change notification settings - Fork 0
/
Box.ts
50 lines (42 loc) · 1.19 KB
/
Box.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Based on CSSBox' "Box" class with minimal set of features to support VIPS.
*/
abstract class Box {
protected node: Node;
protected rootelem: boolean;
protected isblock: boolean;
protected displayed: boolean;
protected visible: boolean;
protected splitted: boolean;
protected constructor(node: Node) {
this.node = node;
this.rootelem = false;
if (this.node.nodeType === Node.ELEMENT_NODE) {
this.isblock = window.getComputedStyle(<Element> this.node).getPropertyValue("display") === "block";
} else {
this.isblock = false;
}
this.displayed = true;
this.visible = true;
this.splitted = false;
}
public getNode(): Node {
return this.node;
}
public isRootElement(): boolean {
return this.rootelem;
}
public isBlock(): boolean {
return this.isblock;
}
public isDisplayed(): boolean {
return this.displayed;
}
public isVisible(): boolean {
return this.visible;
}
public makeRoot(): void {
this.rootelem = true;
}
abstract getText(): string;
}