1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-30 18:19:04 +02:00

much better sketch resetting using DOM rebuild

This commit is contained in:
Pomax
2020-09-16 22:43:16 -07:00
parent 4861c3a63b
commit ab4dd877ee
8 changed files with 292 additions and 194 deletions

View File

@@ -256,7 +256,15 @@ class GraphicsElement extends CustomElement {
* Reload this graphics element the brute force way.
*/
async reset() {
this.outerHTML = this.originalHTML;
const parent = this.parentNode;
const offDOM = document.createElement(`div`);
offDOM.innerHTML = this.originalHTML;
const newElement = offDOM.querySelector(`graphics-element`);
offDOM.style.display = `none`;
document.body.append(offDOM);
newElement.addEventListener(`loaded`, () =>
parent.replaceChild(newElement, this)
);
}
/**
@@ -284,6 +292,7 @@ class GraphicsElement extends CustomElement {
// If we get here, there were no source code errors: undo the scheduled error print.
clearTimeout(this.errorPrintTimeout);
this.render();
this.dispatchEvent(new CustomEvent(`loaded`));
}
/**