1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-01 04:22:28 +02:00

siiiiiigh

This commit is contained in:
Pomax
2020-08-11 18:08:03 -07:00
parent 9b2d0241e6
commit b064c931a5
2 changed files with 17 additions and 14 deletions

View File

@@ -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.

View File

@@ -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 };