Small refactoring, several tests added

This commit is contained in:
barsdeveloper
2023-01-26 22:02:43 +01:00
parent abc19f831a
commit 60b477ac62
24 changed files with 594 additions and 68 deletions

View File

@@ -69,8 +69,10 @@ export default class BlueprintTemplate extends ITemplate {
const bounding = this.viewportElement.getBoundingClientRect()
this.viewportSize[0] = bounding.width
this.viewportSize[1] = bounding.height
this.blueprint.requestUpdate()
this.blueprint.updateComplete.then(() => this.centerContentInViewport())
if (this.blueprint.nodes.length > 0) {
this.blueprint.requestUpdate()
this.blueprint.updateComplete.then(() => this.centerContentInViewport())
}
}
cleanup() {
@@ -186,6 +188,10 @@ export default class BlueprintTemplate extends ITemplate {
))
}
getCopyInputObject() {
return this.getInputObject(Copy)
}
/**
* @param {Number} x
* @param {Number} y

View File

@@ -31,6 +31,14 @@ export default class ITemplate {
return /** @type {IInput[]} */([])
}
/**
* @template {IInput} T
* @param {new () => T} type
*/
getInputObject(type) {
return /** @type {T} */(this.inputObjects.find(object => object.constructor == type))
}
setup() {
this.#inputObjects.forEach(v => v.setup())
}