Compare commits
No commits in common. "bf9908ded12e2e68cf02feb7a051664f2e2a46b2" and "18e3b13fdc0566768cdd675c6755f133894a8935" have entirely different histories.
bf9908ded1
...
18e3b13fdc
1 changed files with 109 additions and 160 deletions
65
main.js
65
main.js
|
@ -27,8 +27,6 @@ const pools = {
|
|||
|
||||
};
|
||||
|
||||
const stears = [];
|
||||
|
||||
/** Stear class */
|
||||
export class Stear{
|
||||
|
||||
|
@ -44,13 +42,6 @@ export class Stear {
|
|||
constructor(elem){
|
||||
this.elem = elem;
|
||||
elem.style.position="relative";
|
||||
stears.push(this);
|
||||
}
|
||||
destroy() {
|
||||
let i = stears.indexOf(this);
|
||||
if (i == -1) return;
|
||||
stears.splice(i, 1);
|
||||
delete this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +145,8 @@ export class Stear {
|
|||
*/
|
||||
static addAnimation(steps, name = "stearAnimation_" + counter++){
|
||||
Stear.addGlobalStyleText(`@keyframes ${name} {
|
||||
${Object.entries(steps).map(([k, d]) =>
|
||||
${
|
||||
Object.entries(steps).map(([k,d])=>
|
||||
` ${k} {
|
||||
${Object.entries(d).map(d => " " + toCssAttr(d[0]) + ": " + d[1] + ";").join("\n")}
|
||||
}`).join("\n")
|
||||
|
@ -212,7 +204,7 @@ ${Object.entries(json).map(d => " " + toCssAttr(d[0]) + ": " + d[1] + ";").jo
|
|||
Object.entries(pools).forEach(([k, d]) => {
|
||||
d.lang = lang;
|
||||
});
|
||||
stears.forEach(s => s.rerenderGlobal());
|
||||
this.globalRenderRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -502,8 +494,6 @@ export class class_ {
|
|||
#find;
|
||||
#doBuild;
|
||||
|
||||
#dynamicState = 0;
|
||||
|
||||
/**
|
||||
* Generate a new Stear render Node.
|
||||
*
|
||||
|
@ -544,7 +534,6 @@ export class class_ {
|
|||
set childs(childs){
|
||||
if (!this.#doBuild) return;
|
||||
this.#childs = Array.isArray(childs) ? childs : [childs];
|
||||
this.#dynamicState = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -566,20 +555,6 @@ export class class_ {
|
|||
}
|
||||
}
|
||||
|
||||
async #syncBuild(args) {
|
||||
for (let i = 0; i < this.#childs.length; i++) {
|
||||
let elem = this.#childs[i];
|
||||
|
||||
if (Array.isArray(elem)) {
|
||||
for (let j = 0; j < elem.length; j++) {
|
||||
if (elem[j] instanceof class_) await elem[j].build(args);
|
||||
}
|
||||
} else {
|
||||
if (elem instanceof class_) await elem.build(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build Stear Structure
|
||||
*
|
||||
|
@ -587,15 +562,11 @@ export class class_ {
|
|||
*/
|
||||
async build (args) {
|
||||
if(!this.#doBuild)return;
|
||||
if (this.#dynamicState < 0) return void await this.#syncBuild(args);
|
||||
this.#build = [];
|
||||
for (let i = 0; i < this.#childs.length; i++) {
|
||||
let elem = this.#childs[i];
|
||||
|
||||
if (typeof elem == "function") {
|
||||
elem = (await elem(...args)) ?? [];
|
||||
this.#dynamicState = 2;
|
||||
}
|
||||
if (typeof elem == "function") elem = (await elem(...args))??[];
|
||||
|
||||
if(Array.isArray(elem)){
|
||||
for (let j = 0; j < elem.length; j++) {
|
||||
|
@ -607,17 +578,6 @@ export class class_ {
|
|||
this.#build.push(elem);
|
||||
}
|
||||
}
|
||||
if (this.#dynamicState <= 0) this.#dynamicState = -1;
|
||||
}
|
||||
|
||||
#syncRender() {
|
||||
let out = [];
|
||||
for (let i = 0; i < this.#build.length; i++) {
|
||||
const elem = this.#build[i];
|
||||
if (typeof elem != "string" && !(elem instanceof LanguagePoolString)) {
|
||||
out[i] = elem.render;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -627,21 +587,15 @@ export class class_ {
|
|||
*/
|
||||
get render (){
|
||||
if (!this.#doBuild) return this.#elem;
|
||||
if (this.#dynamicState < -1) {
|
||||
this.#syncRender();
|
||||
return this.#elem;
|
||||
}
|
||||
let out = [];
|
||||
this.#elem.innerHTML = "";
|
||||
for (let i = 0; i < this.#build.length; i++) {
|
||||
const elem = this.#build[i];
|
||||
if (typeof elem == "string" || elem instanceof LanguagePoolString) {
|
||||
out[i] = document.createTextNode(String(elem));
|
||||
this.#elem.appendChild(document.createTextNode(String(elem)));
|
||||
} else {
|
||||
out[i] = elem.render;
|
||||
this.#elem.appendChild(elem.render);
|
||||
}
|
||||
}
|
||||
this.#elem.replaceChildren(...out);
|
||||
if (this.#dynamicState < 0) this.#dynamicState = -2;
|
||||
return this.#elem;
|
||||
}
|
||||
|
||||
|
@ -652,11 +606,6 @@ export class class_ {
|
|||
return this.#elem;
|
||||
}
|
||||
|
||||
async rerender(args = []) {
|
||||
await this.build(args);
|
||||
this.render;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns find Object
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue