1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-26 16:19:03 +02:00

offsetting

This commit is contained in:
Pomax
2020-09-04 22:01:35 -07:00
parent 83dcab57cb
commit 7e5c6e2eba
38 changed files with 15520 additions and 412 deletions

View File

@@ -191,18 +191,22 @@ class GraphicsElement extends CustomElement {
const globalCode = split.quasiGlobal;
const classCode = performCodeSurgery(split.classCode);
this.setupCodeInjection(uid, globalCode, classCode, rerender);
this.setupCodeInjection(src, uid, globalCode, classCode, rerender);
}
/**
* Form the final, perfectly valid JS module code, and create the <script>
* element for it, to be inserted into the shadow DOM during render().
*/
setupCodeInjection(uid, globalCode, classCode, rerender) {
setupCodeInjection(src, uid, globalCode, classCode, rerender) {
const width = this.getAttribute(`width`, 200);
const height = this.getAttribute(`height`, 200);
this.code = `
/**
* Program source: ${src}
* Data attributes: ${JSON.stringify(this.dataset)}
*/
import { GraphicsAPI, Bezier, Vector, Matrix, Shape } from "${MODULE_PATH}/api/graphics-api.js";
${globalCode}
@@ -300,22 +304,6 @@ class GraphicsElement extends CustomElement {
CustomElement.register(GraphicsElement);
// This is ridiculous, but the easiest way to fix the mess that is
// Firefox's handling of scroll position when custom elements contain
// focussabable, slotted elements is to just force-scroll the document,
// so that it knows where it actually is. Similarly, if this is a hash
// navigation, force that hash. Chrome does not have this problem.
if (typeof window !== undefined) {
window.addEventListener(`DOMContentReady`, (evt) => window.scrollBy(0, 1));
setTimeout(() => {
if (window.location.hash) {
window.location.hash = window.location.hash;
} else {
window.scrollBy(0, 1);
}
}, 200);
}
// debugging should be behind a flag
function debugLog(...data) {
if (GraphicsElement.DEBUG) {