mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-09-01 04:22:28 +02:00
siiiiiigh
This commit is contained in:
@@ -89,6 +89,7 @@ class GraphicsAPI extends BaseAPI {
|
||||
} else {
|
||||
for (let i = 0, e = this.moveable.length, p; i < e; i++) {
|
||||
p = this.moveable[i];
|
||||
console.log(p, this.cursor);
|
||||
if (new Vector(p).dist(this.cursor) <= 5) {
|
||||
this.setCursor(this.HAND);
|
||||
return; // NOTE: this is a return, not a break.
|
||||
|
@@ -32,9 +32,9 @@ class GraphicsElement extends CustomElement {
|
||||
return `
|
||||
:host([hidden]) { display: none; }
|
||||
:host style { display: none; }
|
||||
:host canvas { display: block; margin: auto; border-radius: 0; box-sizing: content-box; }
|
||||
:host canvas:focus { border: 1px solid red; margin:-1px; }
|
||||
:host a.view-source { float: left; font-size: 60%; text-decoration: none; }
|
||||
:host canvas { position: relative; z-index: 1; display: block; margin: auto; border-radius: 0; box-sizing: content-box!important; padding: 1px; }
|
||||
:host canvas:focus { border: 1px solid red; padding: 0px; }
|
||||
:host a.view-source { display: block; position:relative; top: -0.6em; margin-bottom: -0.2em; font-size: 60%; text-decoration: none; }
|
||||
:host label { display: block; font-style:italic; font-size: 0.9em; text-align: right; }
|
||||
`;
|
||||
}
|
||||
@@ -180,16 +180,8 @@ class GraphicsElement extends CustomElement {
|
||||
// browser landscape, so this is the best I can give you right now. I am more
|
||||
// disappointed about this than you will ever be.
|
||||
this.canvas.setAttribute(`tabindex`, `0`);
|
||||
const fixedFocus = evt => {
|
||||
if (evt.target===this.canvas) {
|
||||
const x = window.scrollX;
|
||||
const y = window.scrollY;
|
||||
this.canvas.focus();
|
||||
window.scrollTo(x,y);
|
||||
}
|
||||
}
|
||||
this.canvas.addEventListener(`touchstart`, fixedFocus);
|
||||
this.canvas.addEventListener(`mousedown`, fixedFocus);
|
||||
this.canvas.addEventListener(`touchstart`, evt => this.canvas.focus());
|
||||
this.canvas.addEventListener(`mousedown`, evt => this.canvas.focus());
|
||||
// If we get here, there were no source code errors: undo the scheduled error print.
|
||||
clearTimeout(this.errorPrintTimeout);
|
||||
this.render();
|
||||
@@ -239,10 +231,20 @@ class GraphicsElement extends CustomElement {
|
||||
`data:text/plain;charset=utf-8,${encodeURIComponent(this.rawCode)}`
|
||||
);
|
||||
a.target = `_blank`;
|
||||
if (this.label) slotParent.insertBefore(a, this.label);
|
||||
if (this.label) slotParent.insertBefore(a, this.canvas);
|
||||
}
|
||||
}
|
||||
|
||||
CustomElement.register(GraphicsElement);
|
||||
|
||||
// This is fucking ridiculous, but the easierst way to fix the
|
||||
// clusterfuck that is Firefox's handling of scroll position when
|
||||
// custom elements have focussabable, slotted elements is to just
|
||||
// force-scroll the document, so that it knows where it actually is.
|
||||
if (typeof window !== undefined) {
|
||||
window.addEventListener(`DOMContentReady`, evt => window.scrollBy(0,1));
|
||||
setTimeout(() => window.scrollBy(0,1),200);
|
||||
}
|
||||
|
||||
export { GraphicsElement };
|
||||
|
||||
|
Reference in New Issue
Block a user