@sealpixel/ui 1.0.0-rc.16 → 1.0.0-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/sealpixel-button.js +1 -1
- package/dist/components/sealpixel-button.js.map +1 -1
- package/dist/components/sealpixel-editor.js +43 -7
- package/dist/components/sealpixel-editor.js.map +1 -1
- package/dist/components/sealpixel-nav.js +1 -1
- package/dist/components/sealpixel-nav.js.map +1 -1
- package/dist/components/sealpixel-slider.d.ts +12 -16
- package/dist/components/sealpixel-slider.js +64 -10
- package/dist/components/sealpixel-slider.js.map +1 -1
- package/dist/components/sealpixel-stage.d.ts +6 -0
- package/dist/components/sealpixel-stage.js +29 -2
- package/dist/components/sealpixel-stage.js.map +1 -1
- package/dist/components/sealpixel-stepper.js +4 -4
- package/dist/components/sealpixel-stepper.js.map +1 -1
- package/dist/components/sealpixel-toolbar.js +3 -3
- package/dist/components/sealpixel-toolbar.js.map +1 -1
- package/dist/tools/crop-rotation.d.ts +12 -0
- package/dist/tools/crop-rotation.js +19 -0
- package/dist/tools/crop-rotation.js.map +1 -1
- package/dist/tools/crop.js +17 -7
- package/dist/tools/crop.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sealpixel-nav.js","sourceRoot":"","sources":["../../src/components/sealpixel-nav.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,yDAAyD;AACzD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,IAAI,CAAC,SAAS,WAAW,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAC3K,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;gCACJ;YACtB,CAAC,CAAC,OACN;QAEE,IAAI,CAAC,YAAY;YACf,CAAC,CAAC,IAAI,CAAA,mFAAmF,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,WAAW,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;gBACzN,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC;gCAC9C;YACtB,CAAC,CAAC,OACN;KACD,CAAC;IACJ,CAAC;IAEO,IAAI,CAAC,IAAY,EAAE,MAAgB;QACzC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChG,CAAC","sourcesContent":["import type { SessionState } from '@sealpixel/core';\nimport { css, html, LitElement, nothing } from 'lit';\nimport { icons } from '../icons.js';\nimport { base } from '../theme.js';\n\n/** Undo, redo, history scrubber, export and download. */\nexport class SealpixelNav extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: flex;\n align-items: center;\n gap: var(--sealpixel-space);\n padding: 4px var(--sealpixel-space);\n background: var(--sealpixel-color-surface);\n border-bottom: 1px solid var(--sealpixel-color-border);\n min-height: var(--sealpixel-toolbar-size);\n min-width: 0;\n container-type: inline-size;\n overflow: hidden;\n }\n sealpixel-button {\n flex: 0 0 auto;\n }\n .history {\n flex: 1;\n display: flex;\n align-items: center;\n gap: var(--sealpixel-space);\n min-width: 0;\n }\n input[type='range'] {\n flex: 1;\n min-width: 60px;\n accent-color: var(--sealpixel-color-accent);\n height: var(--sealpixel-touch-target);\n margin: 0;\n appearance: none;\n background: transparent;\n }\n input[type='range']::-webkit-slider-runnable-track {\n height: 3px;\n border-radius: 999px;\n background: var(--sealpixel-color-surface-3, var(--sealpixel-color-border));\n }\n input[type='range']::-moz-range-track {\n height: 3px;\n border-radius: 999px;\n background: var(--sealpixel-color-surface-3, var(--sealpixel-color-border));\n }\n input[type='range']::-webkit-slider-thumb {\n appearance: none;\n width: 16px;\n height: 16px;\n margin-top: -6.5px;\n border-radius: 50%;\n background: var(--sealpixel-color-accent);\n border: 3px solid var(--sealpixel-color-surface);\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);\n }\n input[type='range']::-moz-range-thumb {\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: var(--sealpixel-color-accent);\n border: 3px solid var(--sealpixel-color-surface);\n }\n .status {\n color: var(--sealpixel-color-fg-muted);\n font-size:
|
|
1
|
+
{"version":3,"file":"sealpixel-nav.js","sourceRoot":"","sources":["../../src/components/sealpixel-nav.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,yDAAyD;AACzD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiFF;KACF,CAAC;aAEc,eAAU,GAAG;QAC3B,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC3B,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QACvB,IAAI,EAAE,EAAE,IAA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f,CAAC,CAAC,IAAI,CAAA,mFAAmF,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,WAAW,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;gBACzN,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC;gCAC9C;YACtB,CAAC,CAAC,OACN;KACD,CAAC;IACJ,CAAC;IAEO,IAAI,CAAC,IAAY,EAAE,MAAgB;QACzC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChG,CAAC","sourcesContent":["import type { SessionState } from '@sealpixel/core';\nimport { css, html, LitElement, nothing } from 'lit';\nimport { icons } from '../icons.js';\nimport { base } from '../theme.js';\n\n/** Undo, redo, history scrubber, export and download. */\nexport class SealpixelNav extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: flex;\n align-items: center;\n gap: var(--sealpixel-space);\n padding: 4px var(--sealpixel-space);\n background: var(--sealpixel-color-surface);\n border-bottom: 1px solid var(--sealpixel-color-border);\n min-height: var(--sealpixel-toolbar-size);\n min-width: 0;\n container-type: inline-size;\n overflow: hidden;\n }\n sealpixel-button {\n flex: 0 0 auto;\n }\n .history {\n flex: 1;\n display: flex;\n align-items: center;\n gap: var(--sealpixel-space);\n min-width: 0;\n }\n input[type='range'] {\n flex: 1;\n min-width: 60px;\n accent-color: var(--sealpixel-color-accent);\n height: var(--sealpixel-touch-target);\n margin: 0;\n appearance: none;\n background: transparent;\n }\n input[type='range']::-webkit-slider-runnable-track {\n height: 3px;\n border-radius: 999px;\n background: var(--sealpixel-color-surface-3, var(--sealpixel-color-border));\n }\n input[type='range']::-moz-range-track {\n height: 3px;\n border-radius: 999px;\n background: var(--sealpixel-color-surface-3, var(--sealpixel-color-border));\n }\n input[type='range']::-webkit-slider-thumb {\n appearance: none;\n width: 16px;\n height: 16px;\n margin-top: -6.5px;\n border-radius: 50%;\n background: var(--sealpixel-color-accent);\n border: 3px solid var(--sealpixel-color-surface);\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);\n }\n input[type='range']::-moz-range-thumb {\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: var(--sealpixel-color-accent);\n border: 3px solid var(--sealpixel-color-surface);\n }\n .status {\n color: var(--sealpixel-color-fg-muted);\n font-size: calc(var(--sealpixel-font-size) * 12 / 14);\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n }\n [part='dimensions'] {\n padding: 4px 10px;\n border-radius: 999px;\n background: var(--sealpixel-color-surface-2);\n }\n .spacer {\n flex: 1;\n }\n @container (max-width: 36rem) {\n .status {\n display: none;\n }\n sealpixel-button[part='export'] {\n display: none;\n }\n }\n `,\n ];\n\n static override properties = {\n state: { attribute: false },\n t: { attribute: false },\n busy: { type: Boolean },\n canExport: { type: Boolean },\n showExport: { type: Boolean },\n showDownload: { type: Boolean },\n showHistory: { type: String },\n downloadLabel: { type: String },\n };\n\n declare state: SessionState | null;\n declare t: (key: string, params?: Record<string, string | number>) => string;\n declare busy: boolean;\n declare canExport: boolean;\n /** False hides Export: nobody listens for the result. */\n declare showExport: boolean;\n /** False hides Download; hosts that only consume `sealpixel:process` set it. */\n declare showDownload: boolean;\n /** `all`: undo, redo and the timeline; `buttons`: undo and redo only; `none`: nothing. */\n declare showHistory: 'all' | 'buttons' | 'none';\n /** Overrides the localized Download label. */\n declare downloadLabel: string | null;\n\n constructor() {\n super();\n this.state = null;\n this.t = (k) => k;\n this.busy = false;\n this.canExport = true;\n this.showExport = true;\n this.showDownload = true;\n this.showHistory = 'all';\n this.downloadLabel = null;\n }\n\n override render() {\n const s = this.state;\n const ready = s?.status === 'ready';\n const total = s?.history.log.ops.length ?? 0;\n const index = s?.history.index ?? 0;\n const out = s?.preview?.geometry.logicalOut;\n return html`\n ${\n this.showHistory === 'none'\n ? nothing\n : html`<sealpixel-button variant=\"ghost\" part=\"undo\" exportparts=\"button\" .label=${this.t('nav.undo')} ?disabled=${!ready || index === 0} @click=${() => this.emit('undo')}>${icons.undo}</sealpixel-button>\n <sealpixel-button variant=\"ghost\" part=\"redo\" exportparts=\"button\" .label=${this.t('nav.redo')} ?disabled=${!ready || index >= total} @click=${() => this.emit('redo')}>${icons.redo}</sealpixel-button>`\n }\n ${\n this.showHistory === 'all'\n ? html`<div class=\"history\">\n <input\n part=\"history\"\n type=\"range\"\n min=\"0\"\n max=${total}\n step=\"1\"\n .value=${String(index)}\n ?disabled=${!ready || total === 0}\n aria-label=${this.t('nav.history')}\n aria-valuetext=${`${index} / ${total}`}\n @input=${(e: Event) => this.emit('time-travel', Number((e.target as HTMLInputElement).value))}\n />\n <span class=\"status\" aria-hidden=\"true\">${index}/${total}</span>\n </div>`\n : html`<div class=\"spacer\"></div>`\n }\n <span class=\"status\" role=\"status\" aria-live=\"polite\" part=\"dimensions\">\n ${out ? this.t('status.dimensions', { width: out.width, height: out.height }) : ''}\n </span>\n ${\n this.showExport\n ? html`<sealpixel-button part=\"export\" exportparts=\"button\" .label=${this.t('nav.export')} ?disabled=${!ready || this.busy || !this.canExport} @click=${() => this.emit('export')}>\n ${this.t('nav.export')}\n </sealpixel-button>`\n : nothing\n }\n ${\n this.showDownload\n ? html`<sealpixel-button variant=\"primary\" part=\"download\" exportparts=\"button\" .label=${this.downloadLabel ?? this.t('nav.download')} ?disabled=${!ready || this.busy || !this.canExport} @click=${() => this.emit('download')}>\n ${icons.download} ${this.downloadLabel ?? this.t('nav.download')}\n </sealpixel-button>`\n : nothing\n }\n `;\n }\n\n private emit(name: string, detail?: unknown): void {\n this.dispatchEvent(new CustomEvent(`nav-${name}`, { detail, bubbles: true, composed: true }));\n }\n}\n"]}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* A value dial. The scale travels under a fixed needle the way a thumbwheel
|
|
4
|
-
* does, instead of a thumb travelling along a rail, because the bar at the
|
|
5
|
-
* bottom of the editor gives a control one row: the number stays in the same
|
|
6
|
-
* place and the moving texture is what shows the change.
|
|
7
|
-
*
|
|
8
|
-
* Underneath it is still `input[type=range]`, so the control keeps native
|
|
9
|
-
* keyboard handling, the `slider` role and the value semantics a screen reader
|
|
10
|
-
* and an audit expect. The input does not take the pointer; the wrapper does,
|
|
11
|
-
* and it moves the value by how far the pointer travelled rather than by where
|
|
12
|
-
* it landed. Dragging a wheel is relative, and a range input is not.
|
|
13
|
-
*
|
|
14
|
-
* Emits `slide` while dragging (tier-A hints) and `commit` on release
|
|
15
|
-
* (dispatch an op). Keyboard: arrows step, shift steps 10x.
|
|
16
|
-
*/
|
|
17
2
|
export declare class SealpixelSlider extends LitElement {
|
|
18
3
|
static styles: import("lit").CSSResult[];
|
|
19
4
|
static properties: {
|
|
@@ -55,14 +40,23 @@ export declare class SealpixelSlider extends LitElement {
|
|
|
55
40
|
constructor();
|
|
56
41
|
render(): import("lit").TemplateResult<1>;
|
|
57
42
|
private dragging;
|
|
43
|
+
/** Whether the current drag has moved the value; a bare click commits nothing. */
|
|
44
|
+
private dragMoved;
|
|
58
45
|
private suppressChange;
|
|
59
46
|
/** Client x where the current drag last moved the value. */
|
|
60
47
|
private lastX;
|
|
48
|
+
/** The commit a keyboard change is waiting to make. */
|
|
49
|
+
private keyCommit;
|
|
50
|
+
disconnectedCallback(): void;
|
|
61
51
|
private get input();
|
|
62
52
|
private clamp;
|
|
53
|
+
/** Rounds to the step and keeps the value in range. */
|
|
54
|
+
private snap;
|
|
63
55
|
/**
|
|
64
56
|
* Rounds to the step, then pulls to the detent when the value passes close
|
|
65
|
-
* to it. Without that, landing exactly on neutral takes luck.
|
|
57
|
+
* to it. Without that, landing exactly on neutral takes luck. For the
|
|
58
|
+
* pointer only: a key moves by less than the detent reaches, and would
|
|
59
|
+
* never get past it.
|
|
66
60
|
*/
|
|
67
61
|
private quantize;
|
|
68
62
|
private onPointerDown;
|
|
@@ -71,4 +65,6 @@ export declare class SealpixelSlider extends LitElement {
|
|
|
71
65
|
private onInput;
|
|
72
66
|
private onChange;
|
|
73
67
|
private onKeydown;
|
|
68
|
+
/** Commits a pending keyboard change now. Nothing pending, nothing done. */
|
|
69
|
+
private commitKeys;
|
|
74
70
|
}
|
|
@@ -13,8 +13,22 @@ import { base } from '../theme.js';
|
|
|
13
13
|
* it landed. Dragging a wheel is relative, and a range input is not.
|
|
14
14
|
*
|
|
15
15
|
* Emits `slide` while dragging (tier-A hints) and `commit` on release
|
|
16
|
-
* (dispatch an op). Keyboard:
|
|
16
|
+
* (dispatch an op). Keyboard: an arrow moves a hundredth of the range, Shift
|
|
17
|
+
* a tenth, each rounded to the step. A key emits `slide` at once and `commit`
|
|
18
|
+
* once the keys have rested for `KEY_REST_MS`, so a held key moves the
|
|
19
|
+
* preview and writes one op, like a drag does. Losing focus commits at once.
|
|
20
|
+
* A click on the dial puts the keyboard on it and writes nothing.
|
|
17
21
|
*/
|
|
22
|
+
/** How long the keys have to rest before a keyboard change commits. */
|
|
23
|
+
const KEY_REST_MS = 250;
|
|
24
|
+
/**
|
|
25
|
+
* The default action of `mousedown` moves focus to the nearest focusable
|
|
26
|
+
* ancestor of its target, which is the editor, and so undoes the focus the
|
|
27
|
+
* pointer handler just gave the input. Prevented, the keyboard stays on the
|
|
28
|
+
* dial the user touched. The compatibility `mousedown` after a touch is
|
|
29
|
+
* covered too.
|
|
30
|
+
*/
|
|
31
|
+
const keepFocus = (e) => e.preventDefault();
|
|
18
32
|
export class SealpixelSlider extends LitElement {
|
|
19
33
|
static { this.styles = [
|
|
20
34
|
base,
|
|
@@ -32,12 +46,12 @@ export class SealpixelSlider extends LitElement {
|
|
|
32
46
|
}
|
|
33
47
|
label {
|
|
34
48
|
color: var(--sealpixel-color-fg-muted);
|
|
35
|
-
font-size:
|
|
49
|
+
font-size: calc(var(--sealpixel-font-size) * 11 / 14);
|
|
36
50
|
letter-spacing: 0.012em;
|
|
37
51
|
}
|
|
38
52
|
/* The value is the thing being read, so it keeps its size. */
|
|
39
53
|
output {
|
|
40
|
-
font-size:
|
|
54
|
+
font-size: calc(var(--sealpixel-font-size) * 13 / 14);
|
|
41
55
|
font-variant-numeric: tabular-nums;
|
|
42
56
|
color: var(--sealpixel-color-fg);
|
|
43
57
|
font-weight: 600;
|
|
@@ -131,14 +145,22 @@ export class SealpixelSlider extends LitElement {
|
|
|
131
145
|
constructor() {
|
|
132
146
|
super();
|
|
133
147
|
this.dragging = false;
|
|
148
|
+
/** Whether the current drag has moved the value; a bare click commits nothing. */
|
|
149
|
+
this.dragMoved = false;
|
|
134
150
|
this.suppressChange = false;
|
|
135
151
|
/** Client x where the current drag last moved the value. */
|
|
136
152
|
this.lastX = 0;
|
|
153
|
+
/** The commit a keyboard change is waiting to make. */
|
|
154
|
+
this.keyCommit = null;
|
|
137
155
|
this.onPointerDown = (e) => {
|
|
138
156
|
if (this.disabled || (e.button !== 0 && e.pointerType === 'mouse'))
|
|
139
157
|
return;
|
|
158
|
+
// A keyboard change still waiting to commit goes first, so the log gets
|
|
159
|
+
// the two changes in the order they were made.
|
|
160
|
+
this.commitKeys();
|
|
140
161
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
141
162
|
this.dragging = true;
|
|
163
|
+
this.dragMoved = false;
|
|
142
164
|
this.suppressChange = false;
|
|
143
165
|
this.lastX = e.clientX;
|
|
144
166
|
// The pointer never reaches the input, so focus it by hand: a drag should
|
|
@@ -157,6 +179,7 @@ export class SealpixelSlider extends LitElement {
|
|
|
157
179
|
return;
|
|
158
180
|
this.lastX = e.clientX;
|
|
159
181
|
this.value = next;
|
|
182
|
+
this.dragMoved = true;
|
|
160
183
|
this.dispatchEvent(new CustomEvent('slide', { detail: next, bubbles: true, composed: true }));
|
|
161
184
|
};
|
|
162
185
|
this.onPointerEnd = (e) => {
|
|
@@ -164,6 +187,10 @@ export class SealpixelSlider extends LitElement {
|
|
|
164
187
|
return;
|
|
165
188
|
this.dragging = false;
|
|
166
189
|
e.currentTarget.releasePointerCapture?.(e.pointerId);
|
|
190
|
+
// A click that moved nothing has nothing to write; it only put the
|
|
191
|
+
// keyboard on the dial.
|
|
192
|
+
if (!this.dragMoved)
|
|
193
|
+
return;
|
|
167
194
|
this.dispatchEvent(new CustomEvent('commit', { detail: this.value, bubbles: true, composed: true }));
|
|
168
195
|
// A `change` from the input can still arrive in a later task; it must not
|
|
169
196
|
// commit the same value twice. Cleared by the next interaction.
|
|
@@ -186,17 +213,32 @@ export class SealpixelSlider extends LitElement {
|
|
|
186
213
|
};
|
|
187
214
|
this.onKeydown = (e) => {
|
|
188
215
|
this.suppressChange = false;
|
|
189
|
-
if (!e.shiftKey)
|
|
190
|
-
return;
|
|
191
216
|
const dir = e.key === 'ArrowRight' || e.key === 'ArrowUp'
|
|
192
217
|
? 1
|
|
193
218
|
: e.key === 'ArrowLeft' || e.key === 'ArrowDown'
|
|
194
219
|
? -1
|
|
195
220
|
: 0;
|
|
196
|
-
if (dir === 0)
|
|
221
|
+
if (dir === 0 || this.disabled)
|
|
197
222
|
return;
|
|
223
|
+
// The native step is the resolution of the value, not a distance worth a
|
|
224
|
+
// key press: on a dial it is one tick, and a press should be seen.
|
|
198
225
|
e.preventDefault();
|
|
199
|
-
|
|
226
|
+
const span = this.max - this.min || 1;
|
|
227
|
+
const next = this.snap(this.value + dir * span * (e.shiftKey ? 0.1 : 0.01));
|
|
228
|
+
if (next === this.value)
|
|
229
|
+
return;
|
|
230
|
+
this.value = next;
|
|
231
|
+
this.dispatchEvent(new CustomEvent('slide', { detail: next, bubbles: true, composed: true }));
|
|
232
|
+
if (this.keyCommit !== null)
|
|
233
|
+
clearTimeout(this.keyCommit);
|
|
234
|
+
this.keyCommit = setTimeout(this.commitKeys, KEY_REST_MS);
|
|
235
|
+
};
|
|
236
|
+
/** Commits a pending keyboard change now. Nothing pending, nothing done. */
|
|
237
|
+
this.commitKeys = () => {
|
|
238
|
+
if (this.keyCommit === null)
|
|
239
|
+
return;
|
|
240
|
+
clearTimeout(this.keyCommit);
|
|
241
|
+
this.keyCommit = null;
|
|
200
242
|
this.dispatchEvent(new CustomEvent('commit', { detail: this.value, bubbles: true, composed: true }));
|
|
201
243
|
};
|
|
202
244
|
this.label = '';
|
|
@@ -222,6 +264,7 @@ export class SealpixelSlider extends LitElement {
|
|
|
222
264
|
<div
|
|
223
265
|
class="dial"
|
|
224
266
|
part="dial"
|
|
267
|
+
@mousedown=${keepFocus}
|
|
225
268
|
@pointerdown=${this.onPointerDown}
|
|
226
269
|
@pointermove=${this.onPointerMove}
|
|
227
270
|
@pointerup=${this.onPointerEnd}
|
|
@@ -243,23 +286,34 @@ export class SealpixelSlider extends LitElement {
|
|
|
243
286
|
@input=${this.onInput}
|
|
244
287
|
@change=${this.onChange}
|
|
245
288
|
@keydown=${this.onKeydown}
|
|
289
|
+
@blur=${this.commitKeys}
|
|
246
290
|
/>
|
|
247
291
|
</div>
|
|
248
292
|
`;
|
|
249
293
|
}
|
|
294
|
+
disconnectedCallback() {
|
|
295
|
+
super.disconnectedCallback();
|
|
296
|
+
this.commitKeys();
|
|
297
|
+
}
|
|
250
298
|
get input() {
|
|
251
299
|
return this.renderRoot.querySelector('input');
|
|
252
300
|
}
|
|
253
301
|
clamp(v) {
|
|
254
302
|
return Math.min(this.max, Math.max(this.min, v));
|
|
255
303
|
}
|
|
304
|
+
/** Rounds to the step and keeps the value in range. */
|
|
305
|
+
snap(v) {
|
|
306
|
+
const stepped = this.step > 0 ? Math.round(v / this.step) * this.step : v;
|
|
307
|
+
return this.clamp(Number(stepped.toFixed(6)));
|
|
308
|
+
}
|
|
256
309
|
/**
|
|
257
310
|
* Rounds to the step, then pulls to the detent when the value passes close
|
|
258
|
-
* to it. Without that, landing exactly on neutral takes luck.
|
|
311
|
+
* to it. Without that, landing exactly on neutral takes luck. For the
|
|
312
|
+
* pointer only: a key moves by less than the detent reaches, and would
|
|
313
|
+
* never get past it.
|
|
259
314
|
*/
|
|
260
315
|
quantize(v) {
|
|
261
|
-
const
|
|
262
|
-
const exact = this.clamp(Number(stepped.toFixed(6)));
|
|
316
|
+
const exact = this.snap(v);
|
|
263
317
|
if (this.detent === null)
|
|
264
318
|
return exact;
|
|
265
319
|
const span = this.max - this.min || 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sealpixel-slider.js","sourceRoot":"","sources":["../../src/components/sealpixel-slider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;aAC7B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkGF;KACF,AArGqB,CAqGpB;aAEc,eAAU,GAAG;QAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACvB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACvB,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACrB,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACrB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACtB,MAAM,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC5B,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;QAC1C,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;KACzB,AATyB,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AAC,QAAQ;qBACZ,IAAI,CAAC,SAAS;;;KAG9B,CAAC;IACJ,CAAC;IASD,IAAY,KAAK;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEO,KAAK,CAAC,CAAS;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;;OAGG;IACK,QAAQ,CAAC,CAAS;QACxB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { base } from '../theme.js';\n\n/**\n * A value dial. The scale travels under a fixed needle the way a thumbwheel\n * does, instead of a thumb travelling along a rail, because the bar at the\n * bottom of the editor gives a control one row: the number stays in the same\n * place and the moving texture is what shows the change.\n *\n * Underneath it is still `input[type=range]`, so the control keeps native\n * keyboard handling, the `slider` role and the value semantics a screen reader\n * and an audit expect. The input does not take the pointer; the wrapper does,\n * and it moves the value by how far the pointer travelled rather than by where\n * it landed. Dragging a wheel is relative, and a range input is not.\n *\n * Emits `slide` while dragging (tier-A hints) and `commit` on release\n * (dispatch an op). Keyboard: arrows step, shift steps 10x.\n */\nexport class SealpixelSlider extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: block;\n --tick: var(--sealpixel-color-fg-muted);\n }\n .row {\n display: flex;\n justify-content: center;\n align-items: baseline;\n gap: calc(var(--sealpixel-space) * 0.75);\n margin-bottom: 2px;\n }\n label {\n color: var(--sealpixel-color-fg-muted);\n font-size: 11px;\n letter-spacing: 0.012em;\n }\n /* The value is the thing being read, so it keeps its size. */\n output {\n font-size: 13px;\n font-variant-numeric: tabular-nums;\n color: var(--sealpixel-color-fg);\n font-weight: 600;\n transition: color var(--sealpixel-transition);\n }\n .dial {\n position: relative;\n height: var(--sealpixel-control-height);\n overflow: hidden;\n cursor: ew-resize;\n touch-action: none;\n /* The ends fade out, so the scale reads as a wheel and not as a rail. */\n mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);\n }\n :host([disabled]) .dial {\n cursor: default;\n opacity: 0.45;\n }\n /*\n * Twice the width of the dial, centred, with the range drawn across its\n * middle half. That leaves half a dial of blank scale at each end, which\n * is exactly the travel needed to bring either end of the range under\n * the needle in the centre.\n */\n .scale {\n position: absolute;\n inset: 0;\n left: -50%;\n width: 200%;\n background-image:\n linear-gradient(to right, var(--sealpixel-color-fg-muted) 0 2px, transparent 2px),\n repeating-linear-gradient(to right, var(--tick) 0 2px, transparent 2px 14px);\n background-size:\n 50% 40%,\n 50% 22%;\n background-position: center center;\n background-repeat: no-repeat;\n opacity: 0.45;\n transition: opacity var(--sealpixel-duration) var(--sealpixel-ease);\n }\n .dial:hover .scale {\n opacity: 0.7;\n }\n .needle {\n position: absolute;\n left: 50%;\n top: 18%;\n bottom: 18%;\n width: 2px;\n margin-left: -1px;\n border-radius: 2px;\n background: var(--sealpixel-color-accent);\n transition: transform var(--sealpixel-duration) var(--sealpixel-ease-spring);\n }\n .dial:active .needle {\n transform: scaleY(1.25);\n }\n /*\n * The input carries the keyboard and the semantics, never the pointer: a\n * range maps a click to where it landed, and a wheel has to move by how\n * far the pointer travelled instead.\n */\n input {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n margin: 0;\n opacity: 0;\n pointer-events: none;\n appearance: none;\n background: transparent;\n }\n .dial:has(input:focus-visible) {\n outline: 2px solid var(--sealpixel-color-focus);\n outline-offset: 2px;\n border-radius: var(--sealpixel-radius-sm);\n }\n `,\n ];\n\n static override properties = {\n label: { type: String },\n value: { type: Number },\n min: { type: Number },\n max: { type: Number },\n step: { type: Number },\n format: { attribute: false },\n disabled: { type: Boolean, reflect: true },\n detent: { type: Number },\n };\n\n declare label: string;\n declare value: number;\n declare min: number;\n declare max: number;\n declare step: number;\n declare format: (v: number) => string;\n declare disabled: boolean;\n /** Value the dial snaps to when it passes close by, usually the neutral one. */\n declare detent: number | null;\n\n constructor() {\n super();\n this.label = '';\n this.value = 0;\n this.min = -1;\n this.max = 1;\n this.step = 0.01;\n this.format = (v) => v.toFixed(2);\n this.disabled = false;\n this.detent = null;\n }\n\n override render() {\n const id = 'slider';\n const span = this.max - this.min || 1;\n const t = (this.value - this.min) / span;\n // The scale is twice as wide as the dial, so half of it is one dial width.\n const travel = (0.5 - t) * 50;\n return html`\n <div class=\"row\">\n <label for=${id}>${this.label}</label>\n <output for=${id} aria-hidden=\"true\">${this.format(this.value)}</output>\n </div>\n <div\n class=\"dial\"\n part=\"dial\"\n @pointerdown=${this.onPointerDown}\n @pointermove=${this.onPointerMove}\n @pointerup=${this.onPointerEnd}\n @pointercancel=${this.onPointerEnd}\n @lostpointercapture=${this.onPointerEnd}\n >\n <div class=\"scale\" style=\"transform:translateX(${travel}%)\"></div>\n <div class=\"needle\"></div>\n <input\n part=\"input\"\n id=${id}\n type=\"range\"\n .value=${String(this.value)}\n min=${this.min}\n max=${this.max}\n step=${this.step}\n ?disabled=${this.disabled}\n aria-valuetext=${this.format(this.value)}\n @input=${this.onInput}\n @change=${this.onChange}\n @keydown=${this.onKeydown}\n />\n </div>\n `;\n }\n\n private dragging = false;\n\n private suppressChange = false;\n\n /** Client x where the current drag last moved the value. */\n private lastX = 0;\n\n private get input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n private clamp(v: number): number {\n return Math.min(this.max, Math.max(this.min, v));\n }\n\n /**\n * Rounds to the step, then pulls to the detent when the value passes close\n * to it. Without that, landing exactly on neutral takes luck.\n */\n private quantize(v: number): number {\n const stepped = this.step > 0 ? Math.round(v / this.step) * this.step : v;\n const exact = this.clamp(Number(stepped.toFixed(6)));\n if (this.detent === null) return exact;\n const span = this.max - this.min || 1;\n return Math.abs(exact - this.detent) < span * 0.015 ? this.detent : exact;\n }\n\n private onPointerDown = (e: PointerEvent) => {\n if (this.disabled || (e.button !== 0 && e.pointerType === 'mouse')) return;\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n this.dragging = true;\n this.suppressChange = false;\n this.lastX = e.clientX;\n // The pointer never reaches the input, so focus it by hand: a drag should\n // leave the keyboard on the control the user just touched.\n this.input?.focus();\n };\n\n private onPointerMove = (e: PointerEvent) => {\n if (!this.dragging) return;\n const width = (e.currentTarget as HTMLElement).clientWidth || 1;\n // One dial width of travel covers the whole range, so a drag is as precise\n // as the rail it replaces.\n const moved = ((e.clientX - this.lastX) / width) * (this.max - this.min);\n const next = this.quantize(this.value + moved);\n if (next === this.value) return;\n this.lastX = e.clientX;\n this.value = next;\n this.dispatchEvent(new CustomEvent('slide', { detail: next, bubbles: true, composed: true }));\n };\n\n private onPointerEnd = (e: PointerEvent) => {\n if (!this.dragging) return;\n this.dragging = false;\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n this.dispatchEvent(\n new CustomEvent('commit', { detail: this.value, bubbles: true, composed: true }),\n );\n // A `change` from the input can still arrive in a later task; it must not\n // commit the same value twice. Cleared by the next interaction.\n this.suppressChange = true;\n setTimeout(() => {\n this.suppressChange = false;\n }, 500);\n };\n\n private onInput = (e: Event) => {\n if (!this.dragging) this.suppressChange = false;\n this.value = Number((e.target as HTMLInputElement).value);\n this.dispatchEvent(\n new CustomEvent('slide', { detail: this.value, bubbles: true, composed: true }),\n );\n };\n\n private onChange = (e: Event) => {\n if (this.dragging || this.suppressChange) return;\n this.value = Number((e.target as HTMLInputElement).value);\n this.dispatchEvent(\n new CustomEvent('commit', { detail: this.value, bubbles: true, composed: true }),\n );\n };\n\n private onKeydown = (e: KeyboardEvent) => {\n this.suppressChange = false;\n if (!e.shiftKey) return;\n const dir =\n e.key === 'ArrowRight' || e.key === 'ArrowUp'\n ? 1\n : e.key === 'ArrowLeft' || e.key === 'ArrowDown'\n ? -1\n : 0;\n if (dir === 0) return;\n e.preventDefault();\n this.value = this.clamp(Number((this.value + dir * this.step * 10).toFixed(6)));\n this.dispatchEvent(\n new CustomEvent('commit', { detail: this.value, bubbles: true, composed: true }),\n );\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sealpixel-slider.js","sourceRoot":"","sources":["../../src/components/sealpixel-slider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC;;;;;;;;;;;;;;;;;;GAkBG;AACH,uEAAuE;AACvE,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,SAAS,GAAG,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;AAExD,MAAM,OAAO,eAAgB,SAAQ,UAAU;aAC7B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AI,IAAI,CAAC,MAAM,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { base } from '../theme.js';\n\n/**\n * A value dial. The scale travels under a fixed needle the way a thumbwheel\n * does, instead of a thumb travelling along a rail, because the bar at the\n * bottom of the editor gives a control one row: the number stays in the same\n * place and the moving texture is what shows the change.\n *\n * Underneath it is still `input[type=range]`, so the control keeps native\n * keyboard handling, the `slider` role and the value semantics a screen reader\n * and an audit expect. The input does not take the pointer; the wrapper does,\n * and it moves the value by how far the pointer travelled rather than by where\n * it landed. Dragging a wheel is relative, and a range input is not.\n *\n * Emits `slide` while dragging (tier-A hints) and `commit` on release\n * (dispatch an op). Keyboard: an arrow moves a hundredth of the range, Shift\n * a tenth, each rounded to the step. A key emits `slide` at once and `commit`\n * once the keys have rested for `KEY_REST_MS`, so a held key moves the\n * preview and writes one op, like a drag does. Losing focus commits at once.\n * A click on the dial puts the keyboard on it and writes nothing.\n */\n/** How long the keys have to rest before a keyboard change commits. */\nconst KEY_REST_MS = 250;\n\n/**\n * The default action of `mousedown` moves focus to the nearest focusable\n * ancestor of its target, which is the editor, and so undoes the focus the\n * pointer handler just gave the input. Prevented, the keyboard stays on the\n * dial the user touched. The compatibility `mousedown` after a touch is\n * covered too.\n */\nconst keepFocus = (e: MouseEvent) => e.preventDefault();\n\nexport class SealpixelSlider extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: block;\n --tick: var(--sealpixel-color-fg-muted);\n }\n .row {\n display: flex;\n justify-content: center;\n align-items: baseline;\n gap: calc(var(--sealpixel-space) * 0.75);\n margin-bottom: 2px;\n }\n label {\n color: var(--sealpixel-color-fg-muted);\n font-size: calc(var(--sealpixel-font-size) * 11 / 14);\n letter-spacing: 0.012em;\n }\n /* The value is the thing being read, so it keeps its size. */\n output {\n font-size: calc(var(--sealpixel-font-size) * 13 / 14);\n font-variant-numeric: tabular-nums;\n color: var(--sealpixel-color-fg);\n font-weight: 600;\n transition: color var(--sealpixel-transition);\n }\n .dial {\n position: relative;\n height: var(--sealpixel-control-height);\n overflow: hidden;\n cursor: ew-resize;\n touch-action: none;\n /* The ends fade out, so the scale reads as a wheel and not as a rail. */\n mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);\n }\n :host([disabled]) .dial {\n cursor: default;\n opacity: 0.45;\n }\n /*\n * Twice the width of the dial, centred, with the range drawn across its\n * middle half. That leaves half a dial of blank scale at each end, which\n * is exactly the travel needed to bring either end of the range under\n * the needle in the centre.\n */\n .scale {\n position: absolute;\n inset: 0;\n left: -50%;\n width: 200%;\n background-image:\n linear-gradient(to right, var(--sealpixel-color-fg-muted) 0 2px, transparent 2px),\n repeating-linear-gradient(to right, var(--tick) 0 2px, transparent 2px 14px);\n background-size:\n 50% 40%,\n 50% 22%;\n background-position: center center;\n background-repeat: no-repeat;\n opacity: 0.45;\n transition: opacity var(--sealpixel-duration) var(--sealpixel-ease);\n }\n .dial:hover .scale {\n opacity: 0.7;\n }\n .needle {\n position: absolute;\n left: 50%;\n top: 18%;\n bottom: 18%;\n width: 2px;\n margin-left: -1px;\n border-radius: 2px;\n background: var(--sealpixel-color-accent);\n transition: transform var(--sealpixel-duration) var(--sealpixel-ease-spring);\n }\n .dial:active .needle {\n transform: scaleY(1.25);\n }\n /*\n * The input carries the keyboard and the semantics, never the pointer: a\n * range maps a click to where it landed, and a wheel has to move by how\n * far the pointer travelled instead.\n */\n input {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n margin: 0;\n opacity: 0;\n pointer-events: none;\n appearance: none;\n background: transparent;\n }\n .dial:has(input:focus-visible) {\n outline: 2px solid var(--sealpixel-color-focus);\n outline-offset: 2px;\n border-radius: var(--sealpixel-radius-sm);\n }\n `,\n ];\n\n static override properties = {\n label: { type: String },\n value: { type: Number },\n min: { type: Number },\n max: { type: Number },\n step: { type: Number },\n format: { attribute: false },\n disabled: { type: Boolean, reflect: true },\n detent: { type: Number },\n };\n\n declare label: string;\n declare value: number;\n declare min: number;\n declare max: number;\n declare step: number;\n declare format: (v: number) => string;\n declare disabled: boolean;\n /** Value the dial snaps to when it passes close by, usually the neutral one. */\n declare detent: number | null;\n\n constructor() {\n super();\n this.label = '';\n this.value = 0;\n this.min = -1;\n this.max = 1;\n this.step = 0.01;\n this.format = (v) => v.toFixed(2);\n this.disabled = false;\n this.detent = null;\n }\n\n override render() {\n const id = 'slider';\n const span = this.max - this.min || 1;\n const t = (this.value - this.min) / span;\n // The scale is twice as wide as the dial, so half of it is one dial width.\n const travel = (0.5 - t) * 50;\n return html`\n <div class=\"row\">\n <label for=${id}>${this.label}</label>\n <output for=${id} aria-hidden=\"true\">${this.format(this.value)}</output>\n </div>\n <div\n class=\"dial\"\n part=\"dial\"\n @mousedown=${keepFocus}\n @pointerdown=${this.onPointerDown}\n @pointermove=${this.onPointerMove}\n @pointerup=${this.onPointerEnd}\n @pointercancel=${this.onPointerEnd}\n @lostpointercapture=${this.onPointerEnd}\n >\n <div class=\"scale\" style=\"transform:translateX(${travel}%)\"></div>\n <div class=\"needle\"></div>\n <input\n part=\"input\"\n id=${id}\n type=\"range\"\n .value=${String(this.value)}\n min=${this.min}\n max=${this.max}\n step=${this.step}\n ?disabled=${this.disabled}\n aria-valuetext=${this.format(this.value)}\n @input=${this.onInput}\n @change=${this.onChange}\n @keydown=${this.onKeydown}\n @blur=${this.commitKeys}\n />\n </div>\n `;\n }\n\n private dragging = false;\n\n /** Whether the current drag has moved the value; a bare click commits nothing. */\n private dragMoved = false;\n\n private suppressChange = false;\n\n /** Client x where the current drag last moved the value. */\n private lastX = 0;\n\n /** The commit a keyboard change is waiting to make. */\n private keyCommit: ReturnType<typeof setTimeout> | null = null;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.commitKeys();\n }\n\n private get input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n private clamp(v: number): number {\n return Math.min(this.max, Math.max(this.min, v));\n }\n\n /** Rounds to the step and keeps the value in range. */\n private snap(v: number): number {\n const stepped = this.step > 0 ? Math.round(v / this.step) * this.step : v;\n return this.clamp(Number(stepped.toFixed(6)));\n }\n\n /**\n * Rounds to the step, then pulls to the detent when the value passes close\n * to it. Without that, landing exactly on neutral takes luck. For the\n * pointer only: a key moves by less than the detent reaches, and would\n * never get past it.\n */\n private quantize(v: number): number {\n const exact = this.snap(v);\n if (this.detent === null) return exact;\n const span = this.max - this.min || 1;\n return Math.abs(exact - this.detent) < span * 0.015 ? this.detent : exact;\n }\n\n private onPointerDown = (e: PointerEvent) => {\n if (this.disabled || (e.button !== 0 && e.pointerType === 'mouse')) return;\n // A keyboard change still waiting to commit goes first, so the log gets\n // the two changes in the order they were made.\n this.commitKeys();\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n this.dragging = true;\n this.dragMoved = false;\n this.suppressChange = false;\n this.lastX = e.clientX;\n // The pointer never reaches the input, so focus it by hand: a drag should\n // leave the keyboard on the control the user just touched.\n this.input?.focus();\n };\n\n private onPointerMove = (e: PointerEvent) => {\n if (!this.dragging) return;\n const width = (e.currentTarget as HTMLElement).clientWidth || 1;\n // One dial width of travel covers the whole range, so a drag is as precise\n // as the rail it replaces.\n const moved = ((e.clientX - this.lastX) / width) * (this.max - this.min);\n const next = this.quantize(this.value + moved);\n if (next === this.value) return;\n this.lastX = e.clientX;\n this.value = next;\n this.dragMoved = true;\n this.dispatchEvent(new CustomEvent('slide', { detail: next, bubbles: true, composed: true }));\n };\n\n private onPointerEnd = (e: PointerEvent) => {\n if (!this.dragging) return;\n this.dragging = false;\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n // A click that moved nothing has nothing to write; it only put the\n // keyboard on the dial.\n if (!this.dragMoved) return;\n this.dispatchEvent(\n new CustomEvent('commit', { detail: this.value, bubbles: true, composed: true }),\n );\n // A `change` from the input can still arrive in a later task; it must not\n // commit the same value twice. Cleared by the next interaction.\n this.suppressChange = true;\n setTimeout(() => {\n this.suppressChange = false;\n }, 500);\n };\n\n private onInput = (e: Event) => {\n if (!this.dragging) this.suppressChange = false;\n this.value = Number((e.target as HTMLInputElement).value);\n this.dispatchEvent(\n new CustomEvent('slide', { detail: this.value, bubbles: true, composed: true }),\n );\n };\n\n private onChange = (e: Event) => {\n if (this.dragging || this.suppressChange) return;\n this.value = Number((e.target as HTMLInputElement).value);\n this.dispatchEvent(\n new CustomEvent('commit', { detail: this.value, bubbles: true, composed: true }),\n );\n };\n\n private onKeydown = (e: KeyboardEvent) => {\n this.suppressChange = false;\n const dir =\n e.key === 'ArrowRight' || e.key === 'ArrowUp'\n ? 1\n : e.key === 'ArrowLeft' || e.key === 'ArrowDown'\n ? -1\n : 0;\n if (dir === 0 || this.disabled) return;\n // The native step is the resolution of the value, not a distance worth a\n // key press: on a dial it is one tick, and a press should be seen.\n e.preventDefault();\n const span = this.max - this.min || 1;\n const next = this.snap(this.value + dir * span * (e.shiftKey ? 0.1 : 0.01));\n if (next === this.value) return;\n this.value = next;\n this.dispatchEvent(new CustomEvent('slide', { detail: next, bubbles: true, composed: true }));\n if (this.keyCommit !== null) clearTimeout(this.keyCommit);\n this.keyCommit = setTimeout(this.commitKeys, KEY_REST_MS);\n };\n\n /** Commits a pending keyboard change now. Nothing pending, nothing done. */\n private commitKeys = () => {\n if (this.keyCommit === null) return;\n clearTimeout(this.keyCommit);\n this.keyCommit = null;\n this.dispatchEvent(\n new CustomEvent('commit', { detail: this.value, bubbles: true, composed: true }),\n );\n };\n}\n"]}
|
|
@@ -39,9 +39,15 @@ export declare class SealpixelStage extends LitElement {
|
|
|
39
39
|
t: {
|
|
40
40
|
attribute: boolean;
|
|
41
41
|
};
|
|
42
|
+
revealed: {
|
|
43
|
+
type: BooleanConstructor;
|
|
44
|
+
state: boolean;
|
|
45
|
+
};
|
|
42
46
|
};
|
|
43
47
|
preview: PreviewState | null;
|
|
44
48
|
pending: boolean;
|
|
49
|
+
/** The first preview has been drawn; the content is shown. */
|
|
50
|
+
revealed: boolean;
|
|
45
51
|
overlay: TemplateResult | null;
|
|
46
52
|
hintFilter: string;
|
|
47
53
|
hintTransform: string;
|
|
@@ -28,9 +28,21 @@ export class SealpixelStage extends LitElement {
|
|
|
28
28
|
touch-action: none;
|
|
29
29
|
user-select: none;
|
|
30
30
|
}
|
|
31
|
+
/*
|
|
32
|
+
* The first preview fades in over the checker instead of cutting in:
|
|
33
|
+
* the image arrives, it does not pop. Later previews draw straight onto
|
|
34
|
+
* the canvas, so only the first one is a reveal. The fade sits on the
|
|
35
|
+
* viewport, so the content's own transition stays the glide and nothing
|
|
36
|
+
* else.
|
|
37
|
+
*/
|
|
31
38
|
.viewport {
|
|
32
39
|
position: absolute;
|
|
33
40
|
inset: 0;
|
|
41
|
+
opacity: 0;
|
|
42
|
+
transition: opacity var(--sealpixel-duration-slow) var(--sealpixel-ease-out);
|
|
43
|
+
}
|
|
44
|
+
.viewport.revealed {
|
|
45
|
+
opacity: 1;
|
|
34
46
|
}
|
|
35
47
|
.content {
|
|
36
48
|
position: absolute;
|
|
@@ -55,6 +67,17 @@ export class SealpixelStage extends LitElement {
|
|
|
55
67
|
box-shadow: var(--sealpixel-shadow, none);
|
|
56
68
|
transition: clip-path var(--sealpixel-duration-slow) var(--sealpixel-ease-out);
|
|
57
69
|
}
|
|
70
|
+
/*
|
|
71
|
+
* A rotation hint eases into its angle, so a key press or a drag turns
|
|
72
|
+
* the picture instead of snapping it. The transition lives on the class
|
|
73
|
+
* and the class leaves with the hint: the rendered turn then lands in
|
|
74
|
+
* one step on top of the hint, and the canvas never swings back to zero.
|
|
75
|
+
*/
|
|
76
|
+
canvas.turning {
|
|
77
|
+
transition:
|
|
78
|
+
clip-path var(--sealpixel-duration-slow) var(--sealpixel-ease-out),
|
|
79
|
+
transform var(--sealpixel-duration) var(--sealpixel-ease-out);
|
|
80
|
+
}
|
|
58
81
|
svg.overlay {
|
|
59
82
|
position: absolute;
|
|
60
83
|
left: 0;
|
|
@@ -80,7 +103,7 @@ export class SealpixelStage extends LitElement {
|
|
|
80
103
|
background: color-mix(in srgb, var(--sealpixel-color-surface) 85%, transparent);
|
|
81
104
|
color: var(--sealpixel-color-fg-muted);
|
|
82
105
|
font: inherit;
|
|
83
|
-
font-size:
|
|
106
|
+
font-size: calc(var(--sealpixel-font-size) * 12 / 14);
|
|
84
107
|
font-variant-numeric: tabular-nums;
|
|
85
108
|
backdrop-filter: blur(6px);
|
|
86
109
|
cursor: pointer;
|
|
@@ -138,6 +161,7 @@ export class SealpixelStage extends LitElement {
|
|
|
138
161
|
zoom: { type: Number },
|
|
139
162
|
panEnabled: { type: Boolean },
|
|
140
163
|
t: { attribute: false },
|
|
164
|
+
revealed: { type: Boolean, state: true },
|
|
141
165
|
}; }
|
|
142
166
|
constructor() {
|
|
143
167
|
super();
|
|
@@ -193,6 +217,7 @@ export class SealpixelStage extends LitElement {
|
|
|
193
217
|
});
|
|
194
218
|
this.preview = null;
|
|
195
219
|
this.pending = false;
|
|
220
|
+
this.revealed = false;
|
|
196
221
|
this.overlay = null;
|
|
197
222
|
this.hintFilter = '';
|
|
198
223
|
this.hintTransform = '';
|
|
@@ -359,6 +384,7 @@ export class SealpixelStage extends LitElement {
|
|
|
359
384
|
ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);
|
|
360
385
|
}
|
|
361
386
|
this.drawnVersion = preview.version;
|
|
387
|
+
this.revealed = true;
|
|
362
388
|
// A real preview landed: drop tier-A hints.
|
|
363
389
|
this.hintFilter = '';
|
|
364
390
|
this.hintTransform = '';
|
|
@@ -399,10 +425,11 @@ export class SealpixelStage extends LitElement {
|
|
|
399
425
|
const transform = `translate(${this.pan.x}px, ${this.pan.y}px) scale(${this.zoom})`;
|
|
400
426
|
const hint = this.hintTransform || this.rotateHint();
|
|
401
427
|
return html `
|
|
402
|
-
<div class="viewport" part="viewport">
|
|
428
|
+
<div class="viewport ${this.revealed ? 'revealed' : ''}" part="viewport">
|
|
403
429
|
<div class="content ${this.glide ? 'glide' : ''}" style="transform:${transform}">
|
|
404
430
|
<canvas
|
|
405
431
|
part="canvas"
|
|
432
|
+
class=${this.hintRotate !== 0 ? 'turning' : ''}
|
|
406
433
|
width=${w}
|
|
407
434
|
height=${h}
|
|
408
435
|
style="filter:${this.hintFilter || 'none'};transform:${hint || 'none'};clip-path:${this.clip || 'none'}"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sealpixel-stage.js","sourceRoot":"","sources":["../../src/components/sealpixel-stage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAuB,MAAM,KAAK,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAEL,KAAK,EACL,MAAM,EACN,eAAe,EACf,UAAU,EACV,OAAO,GACR,MAAM,oBAAoB,CAAC;AAG5B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;aAC5B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiHF;KACF,AApHqB,CAoHpB;aAEc,eAAU,GAAG;QAC3B,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;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AC;qBACA,CAAC;4BACM,IAAI,CAAC,UAAU,IAAI,MAAM,cAAc,IAAI,IAAI,MAAM,cAAc,IAAI,CAAC,IAAI,IAAI,MAAM;;;;YAKtG,IAAI,CAAC,OAAO;YACV,CAAC,CAAC,GAAG,CAAA,6CAA6C,CAAC,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,QAAQ;YAC/G,CAAC,CAAC,IACN;;;QAGF,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,gDAAgD,CAAC,CAAC,CAAC,IAAI;;;;;oBAK9D,IAAI,CAAC,MAAM;gBACf,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC;qBACd,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE;iBAC/F,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;SAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;KAC/B,CAAC;IACJ,CAAC;;AAGH,SAAS,KAAK,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { Geometry, PreviewState } from '@sealpixel/core';\nimport { css, html, LitElement, svg, type TemplateResult } from 'lit';\nimport { GestureController } from '../controllers/gesture-controller.js';\nimport { base } from '../theme.js';\nimport {\n type Affine,\n apply,\n invert,\n previewToSource,\n sameAffine,\n scaleOf,\n} from '../view-mapping.js';\n\ntype Translate = (key: string, params?: Record<string, string | number>) => string;\nconst DOUBLE_TAP_MS = 350;\nconst DOUBLE_TAP_PX = 24;\n\n/**\n * Shows the preview on a canvas, fitted and zoomable, with an SVG overlay in\n * image pixel coordinates for tool gizmos. Tier-A hints (CSS filter and\n * transform) are applied to the canvas until the next preview arrives.\n */\nexport class SealpixelStage extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: block;\n position: relative;\n overflow: hidden;\n background-color: var(--sealpixel-color-bg);\n background-image:\n linear-gradient(45deg, var(--sealpixel-stage-checker-a) 25%, transparent 25%),\n linear-gradient(-45deg, var(--sealpixel-stage-checker-a) 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, var(--sealpixel-stage-checker-a) 75%),\n linear-gradient(-45deg, transparent 75%, var(--sealpixel-stage-checker-a) 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0;\n touch-action: none;\n user-select: none;\n }\n .viewport {\n position: absolute;\n inset: 0;\n }\n .content {\n position: absolute;\n left: 0;\n top: 0;\n transform-origin: 0 0;\n will-change: transform;\n }\n /*\n * Only a view the user did not drag glides: a fit, a double tap, a\n * re-anchor after the geometry changed. A pinch, a wheel and a drag must\n * track the pointer exactly, so they clear the class in the same update\n * that writes the new transform and the image never lags behind a finger.\n */\n .content.glide {\n transition: transform var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n canvas {\n display: block;\n image-rendering: auto;\n transform-origin: 50% 50%;\n box-shadow: var(--sealpixel-shadow, none);\n transition: clip-path var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n svg.overlay {\n position: absolute;\n left: 0;\n top: 0;\n overflow: visible;\n pointer-events: none;\n }\n svg.overlay [data-interactive] {\n pointer-events: all;\n }\n /* The outline from the base styles scales with the zoom on an SVG shape;\n the stroke stays put and every engine paints it. */\n svg.overlay [tabindex]:focus-visible {\n stroke: var(--sealpixel-color-focus);\n }\n .status {\n position: absolute;\n right: var(--sealpixel-space);\n bottom: var(--sealpixel-space);\n padding: 3px 9px;\n border: 0;\n border-radius: 999px;\n background: color-mix(in srgb, var(--sealpixel-color-surface) 85%, transparent);\n color: var(--sealpixel-color-fg-muted);\n font: inherit;\n font-size: 12px;\n font-variant-numeric: tabular-nums;\n backdrop-filter: blur(6px);\n cursor: pointer;\n transition:\n color var(--sealpixel-transition),\n background var(--sealpixel-transition),\n opacity var(--sealpixel-duration) var(--sealpixel-ease);\n }\n /* Fitted means the button does nothing; it fades back rather than vanishing. */\n .status:disabled {\n cursor: default;\n opacity: 0.55;\n }\n .status:not(:disabled):hover {\n color: var(--sealpixel-color-fg);\n background: color-mix(in srgb, var(--sealpixel-color-surface) 96%, transparent);\n }\n .status:focus-visible {\n outline: 2px solid var(--sealpixel-color-focus);\n outline-offset: 2px;\n }\n /*\n * A full render is in flight. The dot breathes instead of sitting still,\n * because a static dot is read as part of the image. It starts at the\n * resting opacity, so a render that finishes within one frame does not\n * flash.\n */\n .pending {\n position: absolute;\n left: var(--sealpixel-space);\n top: var(--sealpixel-space);\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--sealpixel-color-accent);\n opacity: 0.8;\n animation: sealpixel-pending 1.4s var(--sealpixel-ease) infinite;\n }\n @keyframes sealpixel-pending {\n 50% {\n opacity: 0.25;\n transform: scale(0.7);\n }\n }\n `,\n ];\n\n static override properties = {\n preview: { attribute: false },\n pending: { type: Boolean },\n overlay: { attribute: false },\n hintFilter: { attribute: false },\n hintTransform: { attribute: false },\n hintRotate: { attribute: false },\n clip: { attribute: false },\n zoom: { type: Number },\n panEnabled: { type: Boolean },\n t: { attribute: false },\n };\n\n declare preview: PreviewState | null;\n declare pending: boolean;\n declare overlay: TemplateResult | null;\n declare hintFilter: string;\n declare hintTransform: string;\n /** A rotation hint in radians. Zero is none. While set, the next preview keeps the zoom. */\n declare hintRotate: number;\n /**\n * A CSS shape the preview is clipped to, or an empty string. A tool uses it\n * to take pixels away rather than paint over them: crop clips to its\n * rectangle so the stage's own backdrop shows around the result, which is\n * the only way the checker carries through without seams. Unlike a hint it\n * survives the next preview, because the tool owns it.\n */\n declare clip: string;\n declare zoom: number;\n declare panEnabled: boolean;\n declare t: Translate;\n\n private canvas: HTMLCanvasElement | null = null;\n private drawnVersion = -1;\n private pan = { x: 0, y: 0 };\n private fitted = false;\n /** Preview px → source px of the drawn preview; a change means the stage shows another view. */\n private viewMap: Affine | null = null;\n private lastTap: { x: number; y: number; at: number } | null = null;\n /**\n * True while the next transform should be animated. Every path that moves the\n * view sets it, so it can never linger from an earlier action into a drag.\n */\n private glide = false;\n /**\n * Set by a tool that wants the next preview to arrive as a movement rather\n * than a cut. Crop uses it: leaving the tool is the moment the image really\n * becomes the crop, and seeing it close is the only signal the user gets\n * that anything happened.\n */\n private glidePending = false;\n private resizeObserver: ResizeObserver | null = null;\n private readonly gestures = new GestureController(this, {\n drag: (e) => {\n if (!this.panEnabled) return;\n this.panBy(e.dx, e.dy);\n },\n // A second tap close to the first fits the image again (double-tap, double-click).\n tap: (e) => {\n const now = performance.now();\n const prev = this.lastTap;\n if (\n prev &&\n now - prev.at < DOUBLE_TAP_MS &&\n Math.hypot(e.x - prev.x, e.y - prev.y) < DOUBLE_TAP_PX\n ) {\n this.lastTap = null;\n this.fit(true);\n return;\n }\n this.lastTap = { x: e.x, y: e.y, at: now };\n },\n pinch: (e) => this.zoomAround(e.scale, e.cx, e.cy, e.dx, e.dy),\n wheelZoom: (e) => this.zoomAround(e.factor, e.cx, e.cy, 0, 0),\n // Plain scrolling pans only while the image is larger than the view;\n // otherwise the page scrolls as the user expects.\n wheelPan: (e) => {\n if (!this.overflows()) return false;\n this.panBy(e.dx, e.dy);\n return true;\n },\n });\n\n constructor() {\n super();\n this.preview = null;\n this.pending = false;\n this.overlay = null;\n this.hintFilter = '';\n this.hintTransform = '';\n this.hintRotate = 0;\n this.clip = '';\n this.zoom = 1;\n this.panEnabled = true;\n this.t = (key) => key;\n }\n\n get geometry(): Geometry | null {\n return this.preview?.geometry ?? null;\n }\n\n get imageWidth(): number {\n return this.preview?.image.width ?? 0;\n }\n\n get imageHeight(): number {\n return this.preview?.image.height ?? 0;\n }\n\n /** Converts a client point into preview image pixels. */\n toImage(clientX: number, clientY: number): { x: number; y: number } {\n const r = this.getBoundingClientRect();\n return {\n x: (clientX - r.left - this.pan.x) / this.zoom,\n y: (clientY - r.top - this.pan.y) / this.zoom,\n };\n }\n\n /** Asks for the next preview-driven view change to be animated, once. */\n glideNextView(): void {\n this.glidePending = true;\n }\n\n /** `glide` animates the move; a resize or a first load must not animate. */\n fit(glide = false): void {\n const w = this.imageWidth;\n const h = this.imageHeight;\n if (!w || !h) return;\n this.glide = glide;\n const r = this.getBoundingClientRect();\n this.zoom = this.fitZoom();\n this.pan = { x: (r.width - w * this.zoom) / 2, y: (r.height - h * this.zoom) / 2 };\n this.fitted = true;\n this.requestUpdate();\n this.viewChanged();\n }\n\n private fitZoom(): number {\n const r = this.getBoundingClientRect();\n const margin = 24;\n const zoom = Math.min(\n (r.width - margin) / this.imageWidth,\n (r.height - margin) / this.imageHeight,\n 4,\n );\n return Math.max(zoom, 0.01);\n }\n\n /**\n * The CSS for a rotation hint: the turn about the centre, at the current\n * zoom. When the turned preview lands, `draw` keeps that zoom (see\n * `turned`), so the render lands on top of the hint.\n */\n private rotateHint(): string {\n const a = this.hintRotate;\n if (!a) return '';\n return `rotate(${(a * 180) / Math.PI}deg)`;\n }\n\n /**\n * The preview now shows another view of the same source (a tool switched\n * between cropped and uncropped, a resize changed the output). Keep the\n * source pixel under the view centre where it was and keep its size on\n * screen, instead of fitting and letting the image jump. A view that was\n * fitted is fitted again only when the steady view would overflow.\n */\n private reanchor(prev: Affine, next: Affine, keepZoom = false): void {\n const r = this.getBoundingClientRect();\n const cx = r.width / 2;\n const cy = r.height / 2;\n const centre = apply(prev, (cx - this.pan.x) / this.zoom, (cy - this.pan.y) / this.zoom);\n const q = apply(invert(next), centre.x, centre.y);\n const zoom = Math.min(16, Math.max(0.05, (this.zoom * scaleOf(prev)) / scaleOf(next)));\n const iw = this.imageWidth * zoom;\n const ih = this.imageHeight * zoom;\n if (!keepZoom && this.fitted && (iw > r.width || ih > r.height)) {\n this.fit();\n return;\n }\n // No glide here on purpose: the point of re-anchoring is that the source\n // region does not appear to move at all. Animating it would show a slide\n // where the contract is that nothing happened.\n this.glide = false;\n this.zoom = zoom;\n this.pan = this.clampPan({ x: cx - q.x * zoom, y: cy - q.y * zoom });\n this.fitted = Math.abs(zoom - this.fitZoom()) < 1e-3;\n this.requestUpdate();\n this.viewChanged();\n }\n\n /** True when the zoomed image is larger than the view in at least one axis. */\n private overflows(): boolean {\n const r = this.getBoundingClientRect();\n return this.imageWidth * this.zoom > r.width || this.imageHeight * this.zoom > r.height;\n }\n\n /**\n * Keeps the image in view: an image smaller than the view stays fully\n * visible, a larger one never shows empty space beyond its edges.\n */\n private clampPan(pan: { x: number; y: number }): { x: number; y: number } {\n const r = this.getBoundingClientRect();\n const iw = this.imageWidth * this.zoom;\n const ih = this.imageHeight * this.zoom;\n if (!iw || !ih) return pan;\n const axis = (v: number, size: number, view: number) =>\n size <= view ? clamp(v, 0, view - size) : clamp(v, view - size, 0);\n return { x: axis(pan.x, iw, r.width), y: axis(pan.y, ih, r.height) };\n }\n\n private panBy(dx: number, dy: number): void {\n const next = this.clampPan({ x: this.pan.x + dx, y: this.pan.y + dy });\n if (next.x === this.pan.x && next.y === this.pan.y) return;\n this.glide = false;\n this.glidePending = false;\n this.pan = next;\n this.requestUpdate();\n this.viewChanged();\n }\n\n /** Zoom or pan changed: overlays scale their gizmos by zoom and must re-render. */\n private viewChanged(): void {\n this.dispatchEvent(\n new CustomEvent('stage-view', { detail: { zoom: this.zoom, pan: this.pan } }),\n );\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.resizeObserver = new ResizeObserver(() => {\n if (this.fitted) this.fit();\n });\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n }\n\n override firstUpdated(): void {\n this.canvas = this.renderRoot.querySelector('canvas');\n this.gestures.attach(this.renderRoot.querySelector('.viewport') as HTMLElement);\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (changed.has('preview')) this.draw();\n }\n\n private draw(): void {\n const canvas = this.canvas;\n const preview = this.preview;\n if (!canvas || !preview) return;\n const { image } = preview;\n const sizeChanged = canvas.width !== image.width || canvas.height !== image.height;\n if (sizeChanged) {\n canvas.width = image.width;\n canvas.height = image.height;\n }\n // A rotation hint says the geometry change about to land is a turn: the\n // view then keeps its zoom, so the image and the crop frame stay where the\n // hint showed them, instead of fitting the larger box and shrinking both.\n const turned = this.hintRotate !== 0;\n if (preview.version !== this.drawnVersion || sizeChanged) {\n const ctx = canvas.getContext('2d');\n if (ctx) {\n const data = new Uint8ClampedArray(image.data.byteLength);\n data.set(image.data);\n ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);\n }\n this.drawnVersion = preview.version;\n // A real preview landed: drop tier-A hints.\n this.hintFilter = '';\n this.hintTransform = '';\n this.hintRotate = 0;\n }\n const nextMap = previewToSource(preview.viewGeometry);\n const prevMap = this.viewMap;\n this.viewMap = nextMap;\n if (this.glidePending) {\n // A tool asked to be seen. Fit rather than re-anchor: a crop that just\n // took half the image away should end up filling the stage, which is\n // what makes the move read as the crop closing.\n this.glidePending = false;\n this.fit(true);\n } else if (prevMap && !sameAffine(prevMap, nextMap)) this.reanchor(prevMap, nextMap, turned);\n else if (!prevMap || (!this.fitted && sizeChanged)) this.fit();\n }\n\n private zoomAround(factor: number, cx: number, cy: number, dx: number, dy: number): void {\n const next = Math.min(16, Math.max(0.05, this.zoom * factor));\n const k = next / this.zoom;\n this.glide = false;\n this.glidePending = false;\n this.zoom = next;\n this.pan = this.clampPan({\n x: cx - (cx - this.pan.x) * k + dx,\n y: cy - (cy - this.pan.y) * k + dy,\n });\n this.fitted = false;\n this.requestUpdate();\n this.viewChanged();\n }\n\n override render() {\n const w = this.imageWidth;\n const h = this.imageHeight;\n const transform = `translate(${this.pan.x}px, ${this.pan.y}px) scale(${this.zoom})`;\n const hint = this.hintTransform || this.rotateHint();\n return html`\n <div class=\"viewport\" part=\"viewport\">\n <div class=\"content ${this.glide ? 'glide' : ''}\" style=\"transform:${transform}\">\n <canvas\n part=\"canvas\"\n width=${w}\n height=${h}\n style=\"filter:${this.hintFilter || 'none'};transform:${hint || 'none'};clip-path:${this.clip || 'none'}\"\n role=\"img\"\n aria-label=\"preview\"\n ></canvas>\n ${\n this.overlay\n ? svg`<svg class=\"overlay\" part=\"overlay\" width=${w} height=${h} viewBox=\"0 0 ${w} ${h}\">${this.overlay}</svg>`\n : null\n }\n </div>\n </div>\n ${this.pending ? html`<div class=\"pending\" aria-hidden=\"true\"></div>` : null}\n <button\n type=\"button\"\n class=\"status\"\n part=\"status\"\n ?disabled=${this.fitted}\n title=${this.t('stage.fit')}\n aria-label=${`${this.t('stage.zoom', { percent: Math.round(this.zoom * 100) })}. ${this.t('stage.fit')}`}\n @click=${() => this.fit(true)}\n >${Math.round(this.zoom * 100)}%</button>\n `;\n }\n}\n\nfunction clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sealpixel-stage.js","sourceRoot":"","sources":["../../src/components/sealpixel-stage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAuB,MAAM,KAAK,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAEL,KAAK,EACL,MAAM,EACN,eAAe,EACf,UAAU,EACV,OAAO,GACR,MAAM,oBAAoB,CAAC;AAG5B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;aAC5B,WAAM,GAAG;QACvB,IAAI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GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;SAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;KAC/B,CAAC;IACJ,CAAC;;AAGH,SAAS,KAAK,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { Geometry, PreviewState } from '@sealpixel/core';\nimport { css, html, LitElement, svg, type TemplateResult } from 'lit';\nimport { GestureController } from '../controllers/gesture-controller.js';\nimport { base } from '../theme.js';\nimport {\n type Affine,\n apply,\n invert,\n previewToSource,\n sameAffine,\n scaleOf,\n} from '../view-mapping.js';\n\ntype Translate = (key: string, params?: Record<string, string | number>) => string;\nconst DOUBLE_TAP_MS = 350;\nconst DOUBLE_TAP_PX = 24;\n\n/**\n * Shows the preview on a canvas, fitted and zoomable, with an SVG overlay in\n * image pixel coordinates for tool gizmos. Tier-A hints (CSS filter and\n * transform) are applied to the canvas until the next preview arrives.\n */\nexport class SealpixelStage extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: block;\n position: relative;\n overflow: hidden;\n background-color: var(--sealpixel-color-bg);\n background-image:\n linear-gradient(45deg, var(--sealpixel-stage-checker-a) 25%, transparent 25%),\n linear-gradient(-45deg, var(--sealpixel-stage-checker-a) 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, var(--sealpixel-stage-checker-a) 75%),\n linear-gradient(-45deg, transparent 75%, var(--sealpixel-stage-checker-a) 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0;\n touch-action: none;\n user-select: none;\n }\n /*\n * The first preview fades in over the checker instead of cutting in:\n * the image arrives, it does not pop. Later previews draw straight onto\n * the canvas, so only the first one is a reveal. The fade sits on the\n * viewport, so the content's own transition stays the glide and nothing\n * else.\n */\n .viewport {\n position: absolute;\n inset: 0;\n opacity: 0;\n transition: opacity var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n .viewport.revealed {\n opacity: 1;\n }\n .content {\n position: absolute;\n left: 0;\n top: 0;\n transform-origin: 0 0;\n will-change: transform;\n }\n /*\n * Only a view the user did not drag glides: a fit, a double tap, a\n * re-anchor after the geometry changed. A pinch, a wheel and a drag must\n * track the pointer exactly, so they clear the class in the same update\n * that writes the new transform and the image never lags behind a finger.\n */\n .content.glide {\n transition: transform var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n canvas {\n display: block;\n image-rendering: auto;\n transform-origin: 50% 50%;\n box-shadow: var(--sealpixel-shadow, none);\n transition: clip-path var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n /*\n * A rotation hint eases into its angle, so a key press or a drag turns\n * the picture instead of snapping it. The transition lives on the class\n * and the class leaves with the hint: the rendered turn then lands in\n * one step on top of the hint, and the canvas never swings back to zero.\n */\n canvas.turning {\n transition:\n clip-path var(--sealpixel-duration-slow) var(--sealpixel-ease-out),\n transform var(--sealpixel-duration) var(--sealpixel-ease-out);\n }\n svg.overlay {\n position: absolute;\n left: 0;\n top: 0;\n overflow: visible;\n pointer-events: none;\n }\n svg.overlay [data-interactive] {\n pointer-events: all;\n }\n /* The outline from the base styles scales with the zoom on an SVG shape;\n the stroke stays put and every engine paints it. */\n svg.overlay [tabindex]:focus-visible {\n stroke: var(--sealpixel-color-focus);\n }\n .status {\n position: absolute;\n right: var(--sealpixel-space);\n bottom: var(--sealpixel-space);\n padding: 3px 9px;\n border: 0;\n border-radius: 999px;\n background: color-mix(in srgb, var(--sealpixel-color-surface) 85%, transparent);\n color: var(--sealpixel-color-fg-muted);\n font: inherit;\n font-size: calc(var(--sealpixel-font-size) * 12 / 14);\n font-variant-numeric: tabular-nums;\n backdrop-filter: blur(6px);\n cursor: pointer;\n transition:\n color var(--sealpixel-transition),\n background var(--sealpixel-transition),\n opacity var(--sealpixel-duration) var(--sealpixel-ease);\n }\n /* Fitted means the button does nothing; it fades back rather than vanishing. */\n .status:disabled {\n cursor: default;\n opacity: 0.55;\n }\n .status:not(:disabled):hover {\n color: var(--sealpixel-color-fg);\n background: color-mix(in srgb, var(--sealpixel-color-surface) 96%, transparent);\n }\n .status:focus-visible {\n outline: 2px solid var(--sealpixel-color-focus);\n outline-offset: 2px;\n }\n /*\n * A full render is in flight. The dot breathes instead of sitting still,\n * because a static dot is read as part of the image. It starts at the\n * resting opacity, so a render that finishes within one frame does not\n * flash.\n */\n .pending {\n position: absolute;\n left: var(--sealpixel-space);\n top: var(--sealpixel-space);\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--sealpixel-color-accent);\n opacity: 0.8;\n animation: sealpixel-pending 1.4s var(--sealpixel-ease) infinite;\n }\n @keyframes sealpixel-pending {\n 50% {\n opacity: 0.25;\n transform: scale(0.7);\n }\n }\n `,\n ];\n\n static override properties = {\n preview: { attribute: false },\n pending: { type: Boolean },\n overlay: { attribute: false },\n hintFilter: { attribute: false },\n hintTransform: { attribute: false },\n hintRotate: { attribute: false },\n clip: { attribute: false },\n zoom: { type: Number },\n panEnabled: { type: Boolean },\n t: { attribute: false },\n revealed: { type: Boolean, state: true },\n };\n\n declare preview: PreviewState | null;\n declare pending: boolean;\n /** The first preview has been drawn; the content is shown. */\n declare revealed: boolean;\n declare overlay: TemplateResult | null;\n declare hintFilter: string;\n declare hintTransform: string;\n /** A rotation hint in radians. Zero is none. While set, the next preview keeps the zoom. */\n declare hintRotate: number;\n /**\n * A CSS shape the preview is clipped to, or an empty string. A tool uses it\n * to take pixels away rather than paint over them: crop clips to its\n * rectangle so the stage's own backdrop shows around the result, which is\n * the only way the checker carries through without seams. Unlike a hint it\n * survives the next preview, because the tool owns it.\n */\n declare clip: string;\n declare zoom: number;\n declare panEnabled: boolean;\n declare t: Translate;\n\n private canvas: HTMLCanvasElement | null = null;\n private drawnVersion = -1;\n private pan = { x: 0, y: 0 };\n private fitted = false;\n /** Preview px → source px of the drawn preview; a change means the stage shows another view. */\n private viewMap: Affine | null = null;\n private lastTap: { x: number; y: number; at: number } | null = null;\n /**\n * True while the next transform should be animated. Every path that moves the\n * view sets it, so it can never linger from an earlier action into a drag.\n */\n private glide = false;\n /**\n * Set by a tool that wants the next preview to arrive as a movement rather\n * than a cut. Crop uses it: leaving the tool is the moment the image really\n * becomes the crop, and seeing it close is the only signal the user gets\n * that anything happened.\n */\n private glidePending = false;\n private resizeObserver: ResizeObserver | null = null;\n private readonly gestures = new GestureController(this, {\n drag: (e) => {\n if (!this.panEnabled) return;\n this.panBy(e.dx, e.dy);\n },\n // A second tap close to the first fits the image again (double-tap, double-click).\n tap: (e) => {\n const now = performance.now();\n const prev = this.lastTap;\n if (\n prev &&\n now - prev.at < DOUBLE_TAP_MS &&\n Math.hypot(e.x - prev.x, e.y - prev.y) < DOUBLE_TAP_PX\n ) {\n this.lastTap = null;\n this.fit(true);\n return;\n }\n this.lastTap = { x: e.x, y: e.y, at: now };\n },\n pinch: (e) => this.zoomAround(e.scale, e.cx, e.cy, e.dx, e.dy),\n wheelZoom: (e) => this.zoomAround(e.factor, e.cx, e.cy, 0, 0),\n // Plain scrolling pans only while the image is larger than the view;\n // otherwise the page scrolls as the user expects.\n wheelPan: (e) => {\n if (!this.overflows()) return false;\n this.panBy(e.dx, e.dy);\n return true;\n },\n });\n\n constructor() {\n super();\n this.preview = null;\n this.pending = false;\n this.revealed = false;\n this.overlay = null;\n this.hintFilter = '';\n this.hintTransform = '';\n this.hintRotate = 0;\n this.clip = '';\n this.zoom = 1;\n this.panEnabled = true;\n this.t = (key) => key;\n }\n\n get geometry(): Geometry | null {\n return this.preview?.geometry ?? null;\n }\n\n get imageWidth(): number {\n return this.preview?.image.width ?? 0;\n }\n\n get imageHeight(): number {\n return this.preview?.image.height ?? 0;\n }\n\n /** Converts a client point into preview image pixels. */\n toImage(clientX: number, clientY: number): { x: number; y: number } {\n const r = this.getBoundingClientRect();\n return {\n x: (clientX - r.left - this.pan.x) / this.zoom,\n y: (clientY - r.top - this.pan.y) / this.zoom,\n };\n }\n\n /** Asks for the next preview-driven view change to be animated, once. */\n glideNextView(): void {\n this.glidePending = true;\n }\n\n /** `glide` animates the move; a resize or a first load must not animate. */\n fit(glide = false): void {\n const w = this.imageWidth;\n const h = this.imageHeight;\n if (!w || !h) return;\n this.glide = glide;\n const r = this.getBoundingClientRect();\n this.zoom = this.fitZoom();\n this.pan = { x: (r.width - w * this.zoom) / 2, y: (r.height - h * this.zoom) / 2 };\n this.fitted = true;\n this.requestUpdate();\n this.viewChanged();\n }\n\n private fitZoom(): number {\n const r = this.getBoundingClientRect();\n const margin = 24;\n const zoom = Math.min(\n (r.width - margin) / this.imageWidth,\n (r.height - margin) / this.imageHeight,\n 4,\n );\n return Math.max(zoom, 0.01);\n }\n\n /**\n * The CSS for a rotation hint: the turn about the centre, at the current\n * zoom. When the turned preview lands, `draw` keeps that zoom (see\n * `turned`), so the render lands on top of the hint.\n */\n private rotateHint(): string {\n const a = this.hintRotate;\n if (!a) return '';\n return `rotate(${(a * 180) / Math.PI}deg)`;\n }\n\n /**\n * The preview now shows another view of the same source (a tool switched\n * between cropped and uncropped, a resize changed the output). Keep the\n * source pixel under the view centre where it was and keep its size on\n * screen, instead of fitting and letting the image jump. A view that was\n * fitted is fitted again only when the steady view would overflow.\n */\n private reanchor(prev: Affine, next: Affine, keepZoom = false): void {\n const r = this.getBoundingClientRect();\n const cx = r.width / 2;\n const cy = r.height / 2;\n const centre = apply(prev, (cx - this.pan.x) / this.zoom, (cy - this.pan.y) / this.zoom);\n const q = apply(invert(next), centre.x, centre.y);\n const zoom = Math.min(16, Math.max(0.05, (this.zoom * scaleOf(prev)) / scaleOf(next)));\n const iw = this.imageWidth * zoom;\n const ih = this.imageHeight * zoom;\n if (!keepZoom && this.fitted && (iw > r.width || ih > r.height)) {\n this.fit();\n return;\n }\n // No glide here on purpose: the point of re-anchoring is that the source\n // region does not appear to move at all. Animating it would show a slide\n // where the contract is that nothing happened.\n this.glide = false;\n this.zoom = zoom;\n this.pan = this.clampPan({ x: cx - q.x * zoom, y: cy - q.y * zoom });\n this.fitted = Math.abs(zoom - this.fitZoom()) < 1e-3;\n this.requestUpdate();\n this.viewChanged();\n }\n\n /** True when the zoomed image is larger than the view in at least one axis. */\n private overflows(): boolean {\n const r = this.getBoundingClientRect();\n return this.imageWidth * this.zoom > r.width || this.imageHeight * this.zoom > r.height;\n }\n\n /**\n * Keeps the image in view: an image smaller than the view stays fully\n * visible, a larger one never shows empty space beyond its edges.\n */\n private clampPan(pan: { x: number; y: number }): { x: number; y: number } {\n const r = this.getBoundingClientRect();\n const iw = this.imageWidth * this.zoom;\n const ih = this.imageHeight * this.zoom;\n if (!iw || !ih) return pan;\n const axis = (v: number, size: number, view: number) =>\n size <= view ? clamp(v, 0, view - size) : clamp(v, view - size, 0);\n return { x: axis(pan.x, iw, r.width), y: axis(pan.y, ih, r.height) };\n }\n\n private panBy(dx: number, dy: number): void {\n const next = this.clampPan({ x: this.pan.x + dx, y: this.pan.y + dy });\n if (next.x === this.pan.x && next.y === this.pan.y) return;\n this.glide = false;\n this.glidePending = false;\n this.pan = next;\n this.requestUpdate();\n this.viewChanged();\n }\n\n /** Zoom or pan changed: overlays scale their gizmos by zoom and must re-render. */\n private viewChanged(): void {\n this.dispatchEvent(\n new CustomEvent('stage-view', { detail: { zoom: this.zoom, pan: this.pan } }),\n );\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.resizeObserver = new ResizeObserver(() => {\n if (this.fitted) this.fit();\n });\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n }\n\n override firstUpdated(): void {\n this.canvas = this.renderRoot.querySelector('canvas');\n this.gestures.attach(this.renderRoot.querySelector('.viewport') as HTMLElement);\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (changed.has('preview')) this.draw();\n }\n\n private draw(): void {\n const canvas = this.canvas;\n const preview = this.preview;\n if (!canvas || !preview) return;\n const { image } = preview;\n const sizeChanged = canvas.width !== image.width || canvas.height !== image.height;\n if (sizeChanged) {\n canvas.width = image.width;\n canvas.height = image.height;\n }\n // A rotation hint says the geometry change about to land is a turn: the\n // view then keeps its zoom, so the image and the crop frame stay where the\n // hint showed them, instead of fitting the larger box and shrinking both.\n const turned = this.hintRotate !== 0;\n if (preview.version !== this.drawnVersion || sizeChanged) {\n const ctx = canvas.getContext('2d');\n if (ctx) {\n const data = new Uint8ClampedArray(image.data.byteLength);\n data.set(image.data);\n ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);\n }\n this.drawnVersion = preview.version;\n this.revealed = true;\n // A real preview landed: drop tier-A hints.\n this.hintFilter = '';\n this.hintTransform = '';\n this.hintRotate = 0;\n }\n const nextMap = previewToSource(preview.viewGeometry);\n const prevMap = this.viewMap;\n this.viewMap = nextMap;\n if (this.glidePending) {\n // A tool asked to be seen. Fit rather than re-anchor: a crop that just\n // took half the image away should end up filling the stage, which is\n // what makes the move read as the crop closing.\n this.glidePending = false;\n this.fit(true);\n } else if (prevMap && !sameAffine(prevMap, nextMap)) this.reanchor(prevMap, nextMap, turned);\n else if (!prevMap || (!this.fitted && sizeChanged)) this.fit();\n }\n\n private zoomAround(factor: number, cx: number, cy: number, dx: number, dy: number): void {\n const next = Math.min(16, Math.max(0.05, this.zoom * factor));\n const k = next / this.zoom;\n this.glide = false;\n this.glidePending = false;\n this.zoom = next;\n this.pan = this.clampPan({\n x: cx - (cx - this.pan.x) * k + dx,\n y: cy - (cy - this.pan.y) * k + dy,\n });\n this.fitted = false;\n this.requestUpdate();\n this.viewChanged();\n }\n\n override render() {\n const w = this.imageWidth;\n const h = this.imageHeight;\n const transform = `translate(${this.pan.x}px, ${this.pan.y}px) scale(${this.zoom})`;\n const hint = this.hintTransform || this.rotateHint();\n return html`\n <div class=\"viewport ${this.revealed ? 'revealed' : ''}\" part=\"viewport\">\n <div class=\"content ${this.glide ? 'glide' : ''}\" style=\"transform:${transform}\">\n <canvas\n part=\"canvas\"\n class=${this.hintRotate !== 0 ? 'turning' : ''}\n width=${w}\n height=${h}\n style=\"filter:${this.hintFilter || 'none'};transform:${hint || 'none'};clip-path:${this.clip || 'none'}\"\n role=\"img\"\n aria-label=\"preview\"\n ></canvas>\n ${\n this.overlay\n ? svg`<svg class=\"overlay\" part=\"overlay\" width=${w} height=${h} viewBox=\"0 0 ${w} ${h}\">${this.overlay}</svg>`\n : null\n }\n </div>\n </div>\n ${this.pending ? html`<div class=\"pending\" aria-hidden=\"true\"></div>` : null}\n <button\n type=\"button\"\n class=\"status\"\n part=\"status\"\n ?disabled=${this.fitted}\n title=${this.t('stage.fit')}\n aria-label=${`${this.t('stage.zoom', { percent: Math.round(this.zoom * 100) })}. ${this.t('stage.fit')}`}\n @click=${() => this.fit(true)}\n >${Math.round(this.zoom * 100)}%</button>\n `;\n }\n}\n\nfunction clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v;\n}\n"]}
|