-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackground.js
35 lines (33 loc) · 930 Bytes
/
Background.js
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
import Component from "./Component.js"
import HTMLElementHelper from "./Helpers/HTMLElementHelper.js"
import ObjectHelper from "./Helpers/ObjectHelper.js"
export default class BackGround extends Component {
constructor() {
super()
}
setImg(img) {
this.img = img
if (this.isBuilt) this.applyBackground()
this.options.pointerEvents = false
return this
}
createAndConfigureContainer() {
super.createAndConfigureContainer()
this.container.style.backgroundSize = "100% 100%"
return this
}
build() {
if (this.size.x == 0 && this.size.y == 0) this.setSizeEqualToParent()
super.build()
this.applyBackground()
return this
}
static copyConfig = ObjectHelper.merge(Component.copyConfig, {
includeProperties: {
img: true,
},
})
applyBackground() {
HTMLElementHelper.setBackgroundImage(this.container, this.img)
}
}