@altnovatrail/canvas 0.3.24 → 0.3.26
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/README.md +1 -1
- package/lib/core/hands.d.ts +11 -7
- package/lib/core/hands.js +30 -8
- package/lib/element/icons.d.ts +0 -36
- package/lib/element/icons.js +0 -44
- package/lib/element/index.d.ts +19 -4
- package/lib/element/index.js +222 -243
- package/lib/element/labels.d.ts +0 -6
- package/lib/element/labels.js +3 -10
- package/lib/element/tools.d.ts +35 -36
- package/lib/element/tools.js +277 -111
- package/package.json +1 -1
package/lib/element/index.js
CHANGED
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
// marks of a submission hold on to the learner's strokes, and a frame shows where each is, over
|
|
9
9
|
// the work (T14; R26). The history of writing comes in and goes out, an event tells of every
|
|
10
10
|
// action, and the work for checking is the crop with the context of its submission (T15; R27).
|
|
11
|
-
//
|
|
12
|
-
//
|
|
11
|
+
// Over it all stand the element's own buttons — the tools the task allows, undo and clearing —
|
|
12
|
+
// labelled in the element's `lang` (T41; R28), on a vertical bar of glass at its left edge (T121;
|
|
13
|
+
// R84). On a tablet a pen's touch puts the page
|
|
13
14
|
// in pen mode, where a finger writes nothing and a button lets it write again, a palm writes
|
|
14
15
|
// nothing, and two fingers scroll (T35; R29). The task comes in the names of the module format
|
|
15
16
|
// 0.4, checked as its schema checks it, and the module's manifest gives the height of a digit and
|
|
16
|
-
// the statement's language (T44; R32).
|
|
17
|
-
//
|
|
17
|
+
// the statement's language (T44; R32). In pen mode one finger drags the sheet too (T121; R84). The
|
|
18
|
+
// workbook's lines, laid out on its page, stand on the template in
|
|
18
19
|
// place of the grid — numbers, text and boxes, which a screen reader reads in the task's order (T51;
|
|
19
20
|
// R35, R36). Each stroke is in one box or in none, by a rule of whole numbers, and `filled` tells
|
|
20
21
|
// which boxes hold one: a filled box's frame is thicker, and its name says so (T48; R37). A
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
// a ring when the keyboard brings the focus there (T93; R33); for a `lang` the labels are not in,
|
|
37
38
|
// the container is in theirs and the column in the element's (T106; R74). The row's Zoom in and Zoom out step
|
|
38
39
|
// the page's zoom of the sheet from its fit to twice it, and a zoomed sheet scrolls across as well
|
|
39
|
-
// as down, with
|
|
40
|
+
// as down, with two fingers, the wheel and the keys (T94).
|
|
40
41
|
import { cellOf, cellsOf, filledOf, sheetFilledOf } from "../core/boxes.js";
|
|
41
42
|
import { Clock } from "../core/clock.js";
|
|
42
43
|
import { ERASER_BUTTON, Eraser } from "../core/eraser.js";
|
|
@@ -50,6 +51,7 @@ import { NO_MANIFEST, settingsOf } from "../core/manifest.js";
|
|
|
50
51
|
import { marksOf, placesOf, shownOf } from "../core/marks.js";
|
|
51
52
|
import { INK_REACH, outline } from "../core/outline.js";
|
|
52
53
|
import { isBox, LAYOUT, pieceWidth, } from "../core/page.js";
|
|
54
|
+
import { encodePNG } from "../core/png.js";
|
|
53
55
|
import { Recorder } from "../core/recorder.js";
|
|
54
56
|
import { fitScale, K_MAX, scaleFor, toSheet } from "../core/screen.js";
|
|
55
57
|
import { SHEET } from "../core/sheet.js";
|
|
@@ -70,6 +72,12 @@ export const TAG = "novatrail-canvas";
|
|
|
70
72
|
const INK = "#111";
|
|
71
73
|
/** The colour of the sheet unless the consumer's theme gives one. */
|
|
72
74
|
const PAPER = "#fff";
|
|
75
|
+
/**
|
|
76
|
+
* The colour of the tool in use and of the focus on the bar unless the consumer's theme gives one,
|
|
77
|
+
* and the bar's glass: the interface mockup's (R84; R148 spec).
|
|
78
|
+
*/
|
|
79
|
+
const ACCENT = "#0071E3";
|
|
80
|
+
const GLASS = "rgba(255, 255, 255, 0.76)";
|
|
73
81
|
/** The event the element sends after every action on the sheet, with the history's new events. */
|
|
74
82
|
const HISTORY_CHANGE = "historychange";
|
|
75
83
|
/** The event the element sends when the learner chooses another tool with its buttons. */
|
|
@@ -92,40 +100,38 @@ const MARK_CORNER = 6;
|
|
|
92
100
|
* the sheet's scale (R22). T22 tries it on devices.
|
|
93
101
|
*/
|
|
94
102
|
const ERASER_RADIUS_PX = 10;
|
|
95
|
-
/**
|
|
96
|
-
* How much of what it shows a press of Up or Down scrolls (R33): four fifths, as WebKit pages on
|
|
97
|
-
* an iPad, so that the last lines stay in sight. T22 tries it on devices.
|
|
98
|
-
*/
|
|
99
|
-
const UP_DOWN = 4 / 5;
|
|
100
103
|
// The statement and the sheet stand in a column of their own, as wide as the element up to
|
|
101
104
|
// 1000 CSS pixels and in its middle beyond, and scroll in a container of their own, by the
|
|
102
105
|
// browser's own scrolling: the wheel, the scroll bar and the keyboard work as anywhere on a page.
|
|
103
106
|
// The page's zoom widens the column with the sheet, to twice its fit, and the container scrolls
|
|
104
107
|
// it across too, left to right whatever the page's direction, while the statement and a demo's
|
|
105
108
|
// parts stay as wide as the fit and stick to its left, in the element's own direction: they wrap
|
|
106
|
-
// as before, and scroll down alone (T94).
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
// in
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
// the
|
|
128
|
-
//
|
|
109
|
+
// as before, and scroll down alone (T94). The layers of the sheet stand in its visible part, the
|
|
110
|
+
// stage, which sticks to the container's top and left, and each shows what lies there, shifted in
|
|
111
|
+
// the frame the ink is drawn in (R18, R23; architecture 3.2 in docs/architecture.md).
|
|
112
|
+
// Over the container, in the same cell of the frame's grid, stands the rail of the element's own
|
|
113
|
+
// buttons: a band as tall as the part of the element in sight and as wide as nothing, sticking to
|
|
114
|
+
// the top of whatever scrolls the element, as far down as the consumer's --novatrail-canvas-top
|
|
115
|
+
// says, and in its middle, 16 pixels from the left edge, the bar of buttons: 52 pixels wide, round
|
|
116
|
+
// at its ends, of the mockup's glass — the fill the consumer's theme gives, blurred behind, or the
|
|
117
|
+
// paper alone where nothing blurs — over the sheet as it scrolls by (R84; R148 spec). A bar taller
|
|
118
|
+
// than the band scrolls inside its glass (1.4.10). A worked example's bar holds the zoom's pair
|
|
119
|
+
// alone, and its Next and Demo stand in a row of the same glass at the band's bottom, the
|
|
120
|
+
// consumer's buttons of the slot actions after them (R84). The tool in use is filled with the
|
|
121
|
+
// accent at an eighth, its icon in the accent; a button in focus shows a ring in the accent; an
|
|
122
|
+
// unavailable one is paler by its colour, not its opacity, which would pale the ring too (2.4.7,
|
|
123
|
+
// 1.4.11). A button's tooltip stands beside it, white on near-black, as the mockup has it. Nothing
|
|
124
|
+
// in the element moves but the scrolling, which jumps, and no tooltip fades (2.3.3). The element is
|
|
125
|
+
// as tall as the statement and the sheet unless it is given a height: then the statement and the
|
|
126
|
+
// sheet scroll in it, under the bar. A worked example's open parts stand between the statement and
|
|
127
|
+
// the sheet, and the region that tells of them is out of sight, but not out of the tree a screen
|
|
128
|
+
// reader reads, where a hidden region would tell nothing (R42). A picture's frame there stands in
|
|
129
|
+
// its item's line, from its top, so that the item's number stands at the top too, as a paragraph's
|
|
130
|
+
// does, and not at the picture's bottom (T64). A picture on an area of the sheet stands on the
|
|
131
|
+
// layer of the author's demo, and the sheet scrolls to a hidden box of the area in its own flow,
|
|
132
|
+
// which neither paints nor takes a pointer (T61). On the canvas the browser neither scrolls nor
|
|
133
|
+
// zooms: the pointer writes, and two fingers scroll by the element's own code (R29), and in pen
|
|
134
|
+
// mode one finger too (R84).
|
|
129
135
|
// The canvas and the buttons take pointer events only as the element does: a consumer's
|
|
130
136
|
// pointer-events: none on the element stops the writing and the buttons' pointer, though not
|
|
131
137
|
// their keys (R20, R28). A worked example's canvas takes no pointer at all: a finger or a pen on
|
|
@@ -142,28 +148,67 @@ const UP_DOWN = 4 / 5;
|
|
|
142
148
|
const STYLE = `
|
|
143
149
|
:host { display: flex; flex-direction: column; isolation: isolate; writing-mode: horizontal-tb; }
|
|
144
150
|
:host([hidden]) { display: none; }
|
|
151
|
+
.frame {
|
|
152
|
+
position: relative; flex: 1 1 auto; min-height: 0; display: grid;
|
|
153
|
+
grid-template: minmax(0, 1fr) / minmax(0, 1fr);
|
|
154
|
+
}
|
|
155
|
+
.viewport {
|
|
156
|
+
grid-area: 1 / 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overflow-anchor: none;
|
|
157
|
+
outline: none; -webkit-tap-highlight-color: transparent;
|
|
158
|
+
}
|
|
159
|
+
.rail {
|
|
160
|
+
grid-area: 1 / 1; align-self: start; justify-self: left; width: 0; direction: ltr;
|
|
161
|
+
position: sticky; top: var(--rail-top, var(--novatrail-canvas-top, 0px)); z-index: 1;
|
|
162
|
+
box-sizing: border-box; padding: 16px 0;
|
|
163
|
+
height: min(100%, var(--rail-room, 100dvh) - var(--rail-top, var(--novatrail-canvas-top, 0px)));
|
|
164
|
+
display: flex; align-items: center;
|
|
165
|
+
}
|
|
166
|
+
.rail[hidden] { display: none; }
|
|
167
|
+
.rail.example { padding-bottom: 88px; }
|
|
145
168
|
.tools {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
169
|
+
box-sizing: border-box; flex: none; width: 52px; max-height: 100%;
|
|
170
|
+
margin: 0 0 0 16px; padding: 4px; border-radius: 26px;
|
|
171
|
+
display: flex; flex-direction: column; align-items: center; gap: 2px;
|
|
172
|
+
overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
|
|
173
|
+
font-size: 14px; line-height: 1.2; color: var(--novatrail-canvas-ink, ${INK});
|
|
174
|
+
background: var(--novatrail-canvas-glass, ${GLASS});
|
|
175
|
+
-webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%);
|
|
176
|
+
box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 8px 28px rgba(0, 0, 0, 0.08),
|
|
177
|
+
0 1px 2px rgba(0, 0, 0, 0.04);
|
|
178
|
+
}
|
|
179
|
+
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
|
180
|
+
.tools { background: var(--novatrail-canvas-paper, ${PAPER}); }
|
|
181
|
+
}
|
|
182
|
+
.tools:dir(rtl) { direction: rtl; }
|
|
183
|
+
.tools.row {
|
|
184
|
+
position: absolute; bottom: 16px; left: calc(var(--rail-width, 100vw) / 2);
|
|
185
|
+
transform: translateX(-50%); width: max-content; max-width: calc(var(--rail-width, 100vw) - 32px);
|
|
186
|
+
max-height: none; margin: 0; padding: 6px; border-radius: 28px; flex-direction: row; gap: 4px;
|
|
187
|
+
overflow-x: auto; overflow-y: hidden;
|
|
150
188
|
}
|
|
151
|
-
.tools.
|
|
152
|
-
.tools .
|
|
153
|
-
|
|
189
|
+
.tools .choice, .tools .zoom { display: flex; flex-direction: column; gap: 2px; flex: none; }
|
|
190
|
+
.tools .line {
|
|
191
|
+
flex: none; width: 24px; height: 1px; margin: 4px 0; background: rgba(0, 0, 0, 0.1);
|
|
154
192
|
}
|
|
155
|
-
.tools
|
|
193
|
+
.tools.row .line { width: 1px; height: 24px; margin: 0 4px; }
|
|
194
|
+
.tools.row ::slotted(*) { flex: none; }
|
|
156
195
|
.tools button {
|
|
157
|
-
box-sizing: border-box; min-width: 44px; min-height: 44px;
|
|
158
|
-
|
|
159
|
-
|
|
196
|
+
box-sizing: border-box; flex: none; min-width: 44px; min-height: 44px; margin: 0;
|
|
197
|
+
padding: 0 14px 0 10px; display: flex; align-items: center; justify-content: center; gap: 6px;
|
|
198
|
+
font: inherit; font-weight: 500; white-space: nowrap; color: inherit; background: transparent;
|
|
199
|
+
cursor: pointer; border: none; border-radius: 22px;
|
|
200
|
+
}
|
|
201
|
+
.tools button.icon { width: 44px; height: 44px; padding: 0; }
|
|
202
|
+
.tools button.icon .label {
|
|
203
|
+
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
|
|
204
|
+
overflow: hidden; clip-path: inset(50%); white-space: nowrap;
|
|
160
205
|
}
|
|
161
206
|
.tools [aria-checked="true"] {
|
|
162
|
-
background:
|
|
163
|
-
|
|
207
|
+
background: color-mix(in srgb, var(--novatrail-canvas-accent, ${ACCENT}) 12%, transparent);
|
|
208
|
+
color: var(--novatrail-canvas-accent, ${ACCENT});
|
|
164
209
|
}
|
|
165
210
|
.tools button:focus-visible {
|
|
166
|
-
outline: 2px solid var(--novatrail-canvas-
|
|
211
|
+
outline: 2px solid var(--novatrail-canvas-accent, ${ACCENT}); outline-offset: 0;
|
|
167
212
|
}
|
|
168
213
|
.tools [aria-disabled="true"] {
|
|
169
214
|
color: color-mix(
|
|
@@ -173,20 +218,18 @@ const STYLE = `
|
|
|
173
218
|
}
|
|
174
219
|
@supports not (color: color-mix(in srgb, red 40%, blue)) {
|
|
175
220
|
.tools [aria-disabled="true"] { opacity: 0.4; }
|
|
221
|
+
.tools [aria-checked="true"] { background: transparent; }
|
|
176
222
|
}
|
|
177
|
-
.tools [hidden] { display: none; }
|
|
178
|
-
.tools button svg {
|
|
179
|
-
display: inline-block; width: 1.125em; height: 1.125em; margin-inline-end: 4px;
|
|
180
|
-
vertical-align: -0.25em; fill: currentColor;
|
|
181
|
-
}
|
|
223
|
+
.tools[hidden], .tools [hidden] { display: none; }
|
|
224
|
+
.tools button svg { display: block; flex: none; width: 20px; height: 20px; fill: currentColor; }
|
|
182
225
|
.tools:dir(rtl) svg.mirrored { transform: scaleX(-1); }
|
|
183
|
-
.
|
|
184
|
-
position:
|
|
185
|
-
|
|
186
|
-
.
|
|
187
|
-
|
|
188
|
-
outline: none; -webkit-tap-highlight-color: transparent;
|
|
226
|
+
.tip {
|
|
227
|
+
position: absolute; left: var(--tip-x, 76px); top: var(--tip-y, 0px); z-index: 2;
|
|
228
|
+
transform: translateY(-50%); white-space: nowrap;
|
|
229
|
+
font-size: 12.5px; font-weight: 500; line-height: 1; padding: 8px 10px; border-radius: 9px;
|
|
230
|
+
background: #1d1d1f; color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
|
|
189
231
|
}
|
|
232
|
+
.tip[hidden] { display: none; }
|
|
190
233
|
.viewport.zoomed { overflow-x: auto; direction: ltr; }
|
|
191
234
|
.ring { position: absolute; inset: 0; z-index: 0; pointer-events: none; display: none; }
|
|
192
235
|
.viewport:focus-visible + .ring {
|
|
@@ -263,12 +306,16 @@ canvas {
|
|
|
263
306
|
.print rect.filled { stroke: Highlight; }
|
|
264
307
|
canvas { color: CanvasText; }
|
|
265
308
|
.marks rect { stroke: Highlight; }
|
|
266
|
-
.tools { background: Canvas; color: CanvasText; }
|
|
267
|
-
.tools
|
|
309
|
+
.tools { background: Canvas; color: CanvasText; border: 1px solid CanvasText; }
|
|
310
|
+
.tools .line { background: CanvasText; }
|
|
311
|
+
.tools button {
|
|
312
|
+
background: ButtonFace; color: ButtonText; border: 1px solid ButtonBorder;
|
|
313
|
+
}
|
|
268
314
|
.tools [aria-checked="true"] {
|
|
269
315
|
background: Highlight; color: HighlightText; border-color: Highlight;
|
|
270
316
|
}
|
|
271
317
|
.tools [aria-disabled="true"] { color: GrayText; border-color: GrayText; }
|
|
318
|
+
.tip { background: Canvas; color: CanvasText; border: 1px solid CanvasText; }
|
|
272
319
|
.tools button:focus-visible, .viewport:focus-visible + .ring { outline-color: Highlight; }
|
|
273
320
|
}
|
|
274
321
|
`;
|
|
@@ -361,14 +408,12 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
361
408
|
#statement = new Statement(this.#pictures);
|
|
362
409
|
/** A worked example's open parts, under its statement, and the region that tells of them (R42). */
|
|
363
410
|
#parts = new Parts(DEMO_IDS, this.#pictures);
|
|
364
|
-
/** The element's own buttons,
|
|
411
|
+
/** The element's own buttons, on a bar over the sheet's left edge (R28, R84). */
|
|
365
412
|
#tools = new Tools({
|
|
366
413
|
choose: (tool) => this.#choose(tool),
|
|
367
414
|
undo: () => this.undo(),
|
|
368
415
|
clear: () => this.clear(),
|
|
369
|
-
upOrDown: (onward) => this.#step(onward, "y"),
|
|
370
416
|
zoom: (larger) => this.#zoomBy(larger),
|
|
371
|
-
leftOrRight: (onward) => this.#step(onward, "x"),
|
|
372
417
|
// The finger writes again on every sheet of the page, with no event: the next pen's touch
|
|
373
418
|
// puts the page back in pen mode (R29).
|
|
374
419
|
fingers: () => {
|
|
@@ -415,34 +460,15 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
415
460
|
*/
|
|
416
461
|
#latch;
|
|
417
462
|
#latchAcross;
|
|
418
|
-
/**
|
|
419
|
-
* A scroll of the page, or of an ancestor of the element in the page's own tree, heard on its way
|
|
420
|
-
* down: Up or Down may have come to an end, or left one (R33). Other scrollers are none of theirs.
|
|
421
|
-
*/
|
|
422
|
-
#heard = (event) => {
|
|
423
|
-
const target = event.target;
|
|
424
|
-
if (target === document || (target instanceof Element && holds(target, this))) {
|
|
425
|
-
// A new --novatrail-canvas-top changes no size: the next scroll is the first to hear of it,
|
|
426
|
-
// by one read of the row's style, and only a new offset asks anew whether the row sticks.
|
|
427
|
-
if (getComputedStyle(this.#tools.element).top !== this.#topSeen)
|
|
428
|
-
this.#stick();
|
|
429
|
-
this.#edges();
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
/**
|
|
433
|
-
* The page grown or shrunk, or the window, the scroller the row sticks in or the row itself: what
|
|
434
|
-
* scrolls the element may have room now, or none, and the row may cover too much of it to stick.
|
|
435
|
-
*/
|
|
463
|
+
/** The page grown or shrunk, or the window: what scrolls the element may have room now, or none. */
|
|
436
464
|
#resized = () => {
|
|
437
|
-
this.#stick();
|
|
438
465
|
this.#region();
|
|
439
|
-
this.#
|
|
466
|
+
this.#fit();
|
|
440
467
|
};
|
|
441
468
|
#page = new ResizeObserver(this.#resized);
|
|
442
|
-
/**
|
|
469
|
+
/** What the bar's rail sticks in, when a scroller of the page's: its height is the rail's room. */
|
|
443
470
|
#port = null;
|
|
444
|
-
|
|
445
|
-
#topSeen = "";
|
|
471
|
+
#ported = new ResizeObserver(() => this.#fit());
|
|
446
472
|
#unwatchPen;
|
|
447
473
|
#unwatchZoom;
|
|
448
474
|
/** The page's zoom as the sheet is laid out by it (T94). */
|
|
@@ -505,8 +531,9 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
505
531
|
this.#area = { width: box.inlineSize, height: box.blockSize };
|
|
506
532
|
}
|
|
507
533
|
// The container's new size, the statement's or that of the list of a demo's parts: each moves
|
|
508
|
-
// the sheet.
|
|
534
|
+
// the sheet, and the first is the room of a worked example's row.
|
|
509
535
|
this.#layout();
|
|
536
|
+
this.#fit();
|
|
510
537
|
});
|
|
511
538
|
/** The size of the container's visible part, in CSS pixels as laid out, before any transform. */
|
|
512
539
|
#area;
|
|
@@ -549,8 +576,9 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
549
576
|
this.#sheet.append(this.#stage, this.#parts.spot);
|
|
550
577
|
this.#column.append(this.#statement.element, this.#parts.list, this.#parts.status, this.#sheet);
|
|
551
578
|
this.#viewport.append(this.#column);
|
|
552
|
-
|
|
553
|
-
|
|
579
|
+
// The bar comes first, as the row of buttons before it did: Tab reaches it before the sheet.
|
|
580
|
+
this.#wrapper.append(this.#tools.rail, this.#viewport, this.#ring);
|
|
581
|
+
root.append(this.#wrapper);
|
|
554
582
|
this.#zoomTo(PAGE_ZOOM.value);
|
|
555
583
|
this.#lay(NO_TASK);
|
|
556
584
|
this.#refresh();
|
|
@@ -601,7 +629,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
601
629
|
this.#adopt("marks");
|
|
602
630
|
}
|
|
603
631
|
/** The element follows its own `lang`: its buttons are labelled in it (R07, R28). */
|
|
604
|
-
static observedAttributes = ["lang"];
|
|
632
|
+
static observedAttributes = ["lang", "tools-hidden"];
|
|
605
633
|
/**
|
|
606
634
|
* What a press of the primary button does: "pen" writes, as the element starts, and "eraser"
|
|
607
635
|
* erases (R22). The learner switches it with the element's own buttons, which say a choice of
|
|
@@ -914,23 +942,26 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
914
942
|
// The page's zoom, on every sheet of it (T94): it may have changed while the element was away.
|
|
915
943
|
this.#zoomTo(PAGE_ZOOM.value);
|
|
916
944
|
this.#unwatchZoom = PAGE_ZOOM.watch(() => this.#zoomed());
|
|
917
|
-
// A
|
|
918
|
-
// page that grows or shrinks scrolls nothing, and neither does a window of another size.
|
|
919
|
-
document.addEventListener("scroll", this.#heard, { capture: true, passive: true });
|
|
945
|
+
// A page that grows or shrinks scrolls nothing, and neither does a window of another size.
|
|
920
946
|
this.#page.observe(document.documentElement);
|
|
921
|
-
// The row wraps anew with the element's width, its language, the canvas kind and the finger's
|
|
922
|
-
// button, and grows or shrinks.
|
|
923
|
-
this.#page.observe(this.#tools.element);
|
|
924
947
|
window.addEventListener("resize", this.#resized);
|
|
925
948
|
this.#refresh();
|
|
949
|
+
this.#fit();
|
|
926
950
|
}
|
|
927
951
|
/**
|
|
928
952
|
* The element's `lang` came, changed or went: its buttons and a workbook's boxes are labelled in
|
|
929
|
-
* it, or in English for a language their labels are not in, and for none (R28, R36).
|
|
930
|
-
* the element
|
|
931
|
-
*
|
|
932
|
-
|
|
933
|
-
|
|
953
|
+
* it, or in English for a language their labels are not in, and for none (R28, R36). Or
|
|
954
|
+
* `tools-hidden` did: while the element has it, the bar is out of sight and of the accessibility
|
|
955
|
+
* tree, as `app` hides it on a phone under its tutor's sheet (R84; В83 in run/QUESTIONS.md). An
|
|
956
|
+
* attribute the element had before it was defined comes here just after the constructor, which
|
|
957
|
+
* reads no attribute.
|
|
958
|
+
*/
|
|
959
|
+
attributeChangedCallback(name) {
|
|
960
|
+
if (name === "tools-hidden") {
|
|
961
|
+
this.#tools.rail.hidden = this.hasAttribute("tools-hidden");
|
|
962
|
+
this.#fit();
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
934
965
|
this.#tools.label(this.getAttribute("lang"));
|
|
935
966
|
this.#nameRegion();
|
|
936
967
|
this.#nameBoxes();
|
|
@@ -1005,6 +1036,43 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1005
1036
|
return null;
|
|
1006
1037
|
return Object.freeze({ png: blobOf(work.png), submission: work.submission });
|
|
1007
1038
|
}
|
|
1039
|
+
/**
|
|
1040
|
+
* The picture of the work, for the `picture` of a stored work that app puts on the server
|
|
1041
|
+
* (contracts/README.md spec, section 15; R83): the PNG of the strokes the surface shows, with no
|
|
1042
|
+
* condition — the whole sheet, or the workbook's whole page with its draft, one pixel a unit,
|
|
1043
|
+
* 1000 × 1400, whatever is filled and whether the work was sent to be checked or not; an empty
|
|
1044
|
+
* surface, and a worked example's, is white. The strokes are those `exportWork()` takes, as the
|
|
1045
|
+
* history has them: not the stroke under way, but those under an eraser not yet lifted. Each is
|
|
1046
|
+
* the outline the screen fills, black on white with no theme and no template, and the pixels go
|
|
1047
|
+
* through the crop's encoder, grey a byte each: so the picture looks as the sheet does, and holds
|
|
1048
|
+
* at most 1,576,640 bytes, for the encoder spends at most 9 bits on a byte of a row, under the
|
|
1049
|
+
* 4 MiB of a stored work.
|
|
1050
|
+
*/
|
|
1051
|
+
async exportPicture() {
|
|
1052
|
+
// A pixel a unit: the ink is 3 px wide, as on a screen of a pixel a unit.
|
|
1053
|
+
const { width, height } = SHEET;
|
|
1054
|
+
const canvas = document.createElement("canvas");
|
|
1055
|
+
canvas.width = width;
|
|
1056
|
+
canvas.height = height;
|
|
1057
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
1058
|
+
if (context === null)
|
|
1059
|
+
throw new Error(`<${TAG}> got no 2D context to draw its picture on`);
|
|
1060
|
+
context.fillStyle = "#fff";
|
|
1061
|
+
context.fillRect(0, 0, width, height);
|
|
1062
|
+
context.fillStyle = "#000";
|
|
1063
|
+
for (const stroke of this.#work.strokes)
|
|
1064
|
+
context.fill(this.#finished(stroke).path);
|
|
1065
|
+
const { data } = context.getImageData(0, 0, width, height);
|
|
1066
|
+
// The canvas's memory goes at once, not at a collection: WebKit caps what all canvases hold.
|
|
1067
|
+
canvas.width = 0;
|
|
1068
|
+
canvas.height = 0;
|
|
1069
|
+
// Black on white: the red of a pixel is its grey. Every index is within the pixels' four bytes
|
|
1070
|
+
// a pixel, so none reads past them.
|
|
1071
|
+
const gray = new Uint8Array(width * height);
|
|
1072
|
+
for (let at = 0; at < gray.length; at++)
|
|
1073
|
+
gray[at] = data[4 * at];
|
|
1074
|
+
return blobOf(encodePNG(gray, width, height));
|
|
1075
|
+
}
|
|
1008
1076
|
disconnectedCallback() {
|
|
1009
1077
|
// A stroke or an erasing under way ends where it is: its pointerup will not reach a sheet off
|
|
1010
1078
|
// the page. Its historychange reaches only the element's own listeners, for the element is in
|
|
@@ -1018,9 +1086,10 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1018
1086
|
this.#unwatchPen = undefined;
|
|
1019
1087
|
this.#unwatchZoom?.();
|
|
1020
1088
|
this.#unwatchZoom = undefined;
|
|
1021
|
-
document.removeEventListener("scroll", this.#heard, { capture: true });
|
|
1022
1089
|
this.#page.disconnect();
|
|
1090
|
+
this.#ported.disconnect();
|
|
1023
1091
|
this.#port = null;
|
|
1092
|
+
this.#tools.disconnect();
|
|
1024
1093
|
window.removeEventListener("resize", this.#resized);
|
|
1025
1094
|
// A stroke that ended here may be the one the other rows of the page waited for.
|
|
1026
1095
|
PEN_MODE.settle();
|
|
@@ -1374,9 +1443,8 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1374
1443
|
* the canvas's top left corner is that of the visible part, and the sheet's width gives `k`, the
|
|
1375
1444
|
* one on the screen, after whatever transform the page puts on the element. The container's
|
|
1376
1445
|
* rectangle gives the part of the canvas it shows: with the statement in sight, the canvas
|
|
1377
|
-
* goes on below the container's bottom. The
|
|
1378
|
-
*
|
|
1379
|
-
* in a low window, it stands above the container and hides nothing of it.
|
|
1446
|
+
* goes on below the container's bottom. The bar of buttons over the sheet takes what is under it
|
|
1447
|
+
* itself: a pointer there presses a button, and writes nothing (R84).
|
|
1380
1448
|
*/
|
|
1381
1449
|
#view() {
|
|
1382
1450
|
const canvas = this.#canvas.getBoundingClientRect();
|
|
@@ -1387,11 +1455,9 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1387
1455
|
const vx = (canvas.left - sheet.left) / k;
|
|
1388
1456
|
const vy = (canvas.top - sheet.top) / k;
|
|
1389
1457
|
const port = clientBoxOf(this.#viewport);
|
|
1390
|
-
// The row ends where the container begins, unless it sticks over it.
|
|
1391
|
-
const row = this.#tools.element.getBoundingClientRect();
|
|
1392
1458
|
const shown = {
|
|
1393
1459
|
left: Math.max(canvas.left, port.left),
|
|
1394
|
-
top: Math.max(canvas.top, port.top
|
|
1460
|
+
top: Math.max(canvas.top, port.top),
|
|
1395
1461
|
right: Math.min(canvas.right, port.right),
|
|
1396
1462
|
bottom: Math.min(canvas.bottom, port.bottom),
|
|
1397
1463
|
};
|
|
@@ -1413,8 +1479,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1413
1479
|
/**
|
|
1414
1480
|
* The top and the left of the visible part from the scroll and the last layout, without reading
|
|
1415
1481
|
* the layout again: the stage sticks to the container's top once the sheet's top has gone past
|
|
1416
|
-
* it, and to its left so.
|
|
1417
|
-
* left one.
|
|
1482
|
+
* it, and to its left so.
|
|
1418
1483
|
*/
|
|
1419
1484
|
#scrolled() {
|
|
1420
1485
|
if (this.#k > 0) {
|
|
@@ -1422,23 +1487,6 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1422
1487
|
this.#vx = Math.max(0, this.#viewport.scrollLeft - this.#sheetAtX) / this.#k;
|
|
1423
1488
|
}
|
|
1424
1489
|
this.#request();
|
|
1425
|
-
this.#edges();
|
|
1426
|
-
}
|
|
1427
|
-
/**
|
|
1428
|
-
* Up or Down was pressed (R33), or along `x` Left or Right (T94): what two fingers would scroll
|
|
1429
|
-
* that way goes by four fifths of what it shows in sight. It is chosen anew at every press, so
|
|
1430
|
-
* that a container at its end hands the scroll on at the next. While a pointer writes or erases
|
|
1431
|
-
* on a sheet of the page, nothing moves under it.
|
|
1432
|
-
*/
|
|
1433
|
-
#step(onward, axis) {
|
|
1434
|
-
const latch = PEN_MODE.writing ? undefined : this.#scrollerFor(onward, axis);
|
|
1435
|
-
if (latch !== undefined) {
|
|
1436
|
-
const seen = this.#seen(latch.target, axis);
|
|
1437
|
-
const step = Math.max(1, Math.round((UP_DOWN * seen) / latch.scale));
|
|
1438
|
-
const by = onward ? step : -step;
|
|
1439
|
-
latch.target.scrollBy({ [axis === "y" ? "top" : "left"]: by, behavior: "instant" });
|
|
1440
|
-
}
|
|
1441
|
-
this.#edges();
|
|
1442
1490
|
}
|
|
1443
1491
|
/**
|
|
1444
1492
|
* Zoom in or Zoom out was pressed (T94): the page's zoom goes a step larger or smaller, and every
|
|
@@ -1487,85 +1535,49 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1487
1535
|
}
|
|
1488
1536
|
}
|
|
1489
1537
|
/**
|
|
1490
|
-
*
|
|
1491
|
-
* it
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1538
|
+
* What the rail's CSS cannot know (R84): the height of what it sticks in — the scroller's, which
|
|
1539
|
+
* it watches, or the window's —, from whose top it runs down to its bottom, below the consumer's
|
|
1540
|
+
* --novatrail-canvas-top; and the element's width, which a worked example's row keeps within, as
|
|
1541
|
+
* the rail is as wide as nothing. A band in pixels is taken as it changes; one in percent, of the
|
|
1542
|
+
* scroller's height as `top` takes it and not of the element's as `height` would, and `auto`,
|
|
1543
|
+
* nothing as `#band` counts it, are taken here, at the next resize.
|
|
1494
1544
|
*/
|
|
1495
|
-
#
|
|
1496
|
-
const
|
|
1497
|
-
if (
|
|
1498
|
-
return
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
if (
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
top = Math.max(top, box.bottom);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
else {
|
|
1511
|
-
top = Math.max(top, this.#band(target));
|
|
1512
|
-
}
|
|
1513
|
-
return bottom > top ? bottom - top : whole;
|
|
1514
|
-
}
|
|
1515
|
-
/**
|
|
1516
|
-
* Whether the row sticks (R28): while it is no taller than a quarter of what it sticks in, below
|
|
1517
|
-
* the consumer's offset. In a lower window, or once it wraps over more of it, it stands in its
|
|
1518
|
-
* place, above the statement, and goes with the scrolling, as WCAG's technique C34 un-fixes a
|
|
1519
|
-
* sticky header (1.4.10, 2.4.11). Its place and its size are the same either way, so the choice
|
|
1520
|
-
* changes nothing it is made from. The scroller it sticks in is watched for its size. Only an
|
|
1521
|
-
* element on the page asks: what calls this goes when the element leaves it.
|
|
1522
|
-
*/
|
|
1523
|
-
#stick() {
|
|
1524
|
-
const room = roomOf(this.#tools.element);
|
|
1545
|
+
#fit() {
|
|
1546
|
+
const rail = this.#tools.rail;
|
|
1547
|
+
if (!this.isConnected || rail.hidden)
|
|
1548
|
+
return;
|
|
1549
|
+
const band = getComputedStyle(this).getPropertyValue("--novatrail-canvas-top").trim();
|
|
1550
|
+
rail.style.removeProperty("--rail-top");
|
|
1551
|
+
if (band === "auto")
|
|
1552
|
+
rail.style.setProperty("--rail-top", "0px");
|
|
1553
|
+
// A sticky box's `top` reads as the pixels it is used at.
|
|
1554
|
+
else if (band.includes("%"))
|
|
1555
|
+
rail.style.setProperty("--rail-top", getComputedStyle(rail).top);
|
|
1556
|
+
const room = roomOf(rail);
|
|
1525
1557
|
if (room.port !== this.#port) {
|
|
1526
1558
|
if (this.#port !== null)
|
|
1527
|
-
this.#
|
|
1528
|
-
if (room.port !== null)
|
|
1529
|
-
this.#page.observe(room.port);
|
|
1559
|
+
this.#ported.unobserve(this.#port);
|
|
1530
1560
|
this.#port = room.port;
|
|
1561
|
+
if (room.port !== null)
|
|
1562
|
+
this.#ported.observe(room.port);
|
|
1531
1563
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
if (tall > 0 && room.height > 0)
|
|
1535
|
-
this.#tools.stick(4 * tall <= room.height - room.offset);
|
|
1536
|
-
this.#topSeen = getComputedStyle(row).top;
|
|
1564
|
+
rail.style.setProperty("--rail-room", `${room.height / scaleOf(rail)}px`);
|
|
1565
|
+
rail.style.setProperty("--rail-width", `${this.#wrapper.clientWidth}px`);
|
|
1537
1566
|
}
|
|
1538
1567
|
/**
|
|
1539
|
-
* Where the consumer's band over the top of what the
|
|
1540
|
-
* offset, --novatrail-canvas-top, below the top of the scroller or of the window — for a
|
|
1541
|
-
* that is or lies within what the
|
|
1568
|
+
* Where the consumer's band over the top of what the bar's rail sticks in ends, down the screen:
|
|
1569
|
+
* its offset, --novatrail-canvas-top, below the top of the scroller or of the window — for a
|
|
1570
|
+
* target that is or lies within what the rail sticks in, and above everything for any other.
|
|
1542
1571
|
*/
|
|
1543
1572
|
#band(target) {
|
|
1544
|
-
const room = roomOf(this.#tools.
|
|
1545
|
-
// The band stands over the top of what the
|
|
1546
|
-
// but not over the page's when the
|
|
1573
|
+
const room = roomOf(this.#tools.rail);
|
|
1574
|
+
// The band stands over the top of what the rail sticks in, and so over a scroller within it,
|
|
1575
|
+
// but not over the page's when the rail sticks in a scroller of its own.
|
|
1547
1576
|
const within = room.port === null
|
|
1548
1577
|
? target !== undefined
|
|
1549
1578
|
: target instanceof Element && (target === room.port || holds(room.port, target));
|
|
1550
1579
|
return within ? room.top + room.offset : Number.NEGATIVE_INFINITY;
|
|
1551
1580
|
}
|
|
1552
|
-
/**
|
|
1553
|
-
* Up and Down as the scrolling now is (R33), and Left and Right while the sheet is zoomed (T94):
|
|
1554
|
-
* each stands unavailable while what two fingers would scroll its way can go no further. The
|
|
1555
|
-
* element hears its container, the page and the ancestors in the page's own tree scroll, and the
|
|
1556
|
-
* page and the window change size, but not the scrolling in another shadow tree: a press asks
|
|
1557
|
-
* anew.
|
|
1558
|
-
*/
|
|
1559
|
-
#edges() {
|
|
1560
|
-
if (!this.isConnected)
|
|
1561
|
-
return;
|
|
1562
|
-
const above = this.#scrollerFor(false) !== undefined;
|
|
1563
|
-
const below = this.#scrollerFor(true) !== undefined;
|
|
1564
|
-
const zoomed = this.#zoom > 1;
|
|
1565
|
-
const before = zoomed && this.#scrollerFor(false, "x") !== undefined;
|
|
1566
|
-
const after = zoomed && this.#scrollerFor(true, "x") !== undefined;
|
|
1567
|
-
this.#tools.edges(above, below, before, after);
|
|
1568
|
-
}
|
|
1569
1581
|
/**
|
|
1570
1582
|
* Two fingers moved right on the screen by `dx` CSS pixels and down it by `dy` (R29), and what
|
|
1571
1583
|
* they scroll goes with them. The gesture's first step down chooses what it scrolls down, for the
|
|
@@ -1680,8 +1692,6 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1680
1692
|
this.#canvas.height = height;
|
|
1681
1693
|
}
|
|
1682
1694
|
this.#draw();
|
|
1683
|
-
// A container of another height, or a statement, may give Up or Down somewhere to go, or none.
|
|
1684
|
-
this.#edges();
|
|
1685
1695
|
}
|
|
1686
1696
|
/** A new density — the window on another screen, the page zoomed — lays the canvas out anew. */
|
|
1687
1697
|
#watchDensity() {
|
|
@@ -1750,9 +1760,9 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1750
1760
|
/**
|
|
1751
1761
|
* The learner opened the next part of the demo with the row's Next (R42). The list grows above
|
|
1752
1762
|
* the sheet, and the layout keeps a sheet scrolled into sight where it was at once, before the
|
|
1753
|
-
* scroll of the container is heard; then the part comes into sight
|
|
1754
|
-
* region tells of it, and whoever listens hears of the new state. The focus stays
|
|
1755
|
-
* opens the part after it. Nothing happens while the demo is hidden, or open whole.
|
|
1763
|
+
* scroll of the container is heard; then the part comes into sight between the band and the row
|
|
1764
|
+
* of glass, the region tells of it, and whoever listens hears of the new state. The focus stays
|
|
1765
|
+
* on Next, which opens the part after it. Nothing happens while the demo is hidden, or open whole.
|
|
1756
1766
|
*/
|
|
1757
1767
|
#openNext() {
|
|
1758
1768
|
const example = this.#example;
|
|
@@ -1850,30 +1860,27 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1850
1860
|
}
|
|
1851
1861
|
/**
|
|
1852
1862
|
* An item of the list, or an area of the sheet, comes into sight at once, as near as it is (R42),
|
|
1853
|
-
* and then out from under the
|
|
1854
|
-
* scrolls back up goes back as far as the
|
|
1855
|
-
*
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
1858
|
-
*
|
|
1859
|
-
*
|
|
1860
|
-
* sight, under the row (T61).
|
|
1863
|
+
* and then out from under the consumer's band, --novatrail-canvas-top, should the band cover
|
|
1864
|
+
* where it came to: what scrolls back up goes back as far as the band covers it. A margin of
|
|
1865
|
+
* scrolling would hold for every scroller of the chain alike — the sheet's container and the
|
|
1866
|
+
* page. An area of the sheet taller than what is in sight comes by its top from below, but by its
|
|
1867
|
+
* bottom from above, and then the band's cover brings its top back into sight (T61). The bar of
|
|
1868
|
+
* buttons covers nothing at the top: it stands at the left edge, and a worked example's row at
|
|
1869
|
+
* the bottom, where a scroll margin keeps what comes from below above it (R84).
|
|
1861
1870
|
*/
|
|
1862
1871
|
#bringIntoSight(item) {
|
|
1872
|
+
// A worked example's row of glass stands over the bottom of what is in sight: what comes into
|
|
1873
|
+
// sight from below stops 16 pixels above it (R84).
|
|
1874
|
+
const { rail, row } = this.#tools;
|
|
1875
|
+
const under = rail.hidden || row.hidden ? 0 : row.offsetHeight + 32;
|
|
1876
|
+
item.style.setProperty("scroll-margin-bottom", `${under}px`);
|
|
1863
1877
|
item.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
1864
|
-
// A scroller that comes to its top hands the rest on to the next
|
|
1865
|
-
//
|
|
1866
|
-
// element's bottom pushed up from where it sticks comes back down as the page scrolls, over
|
|
1867
|
-
// what the scroll brought out, and the next brings it out again (T94).
|
|
1878
|
+
// A scroller that comes to its top hands the rest on to the next. A scroller goes again only
|
|
1879
|
+
// while each of its scrolls leaves less covered than the last (T94).
|
|
1868
1880
|
const covered = new Map();
|
|
1869
1881
|
for (;;) {
|
|
1870
1882
|
const latch = this.#scrollerFor(false);
|
|
1871
|
-
|
|
1872
|
-
// what the row sticks in.
|
|
1873
|
-
const over = this.#tools.sticks
|
|
1874
|
-
? this.#tools.element.getBoundingClientRect().bottom
|
|
1875
|
-
: this.#band(latch?.target);
|
|
1876
|
-
const cover = over - item.getBoundingClientRect().top;
|
|
1883
|
+
const cover = this.#band(latch?.target) - item.getBoundingClientRect().top;
|
|
1877
1884
|
if (cover <= EDGE || latch === undefined)
|
|
1878
1885
|
return;
|
|
1879
1886
|
const last = covered.get(latch.target);
|
|
@@ -2321,34 +2328,6 @@ function scrollsOn(element, onward, axis = "y") {
|
|
|
2321
2328
|
const at = scrolledOf(element, axis);
|
|
2322
2329
|
return onward ? at < overflowOf(element, axis) - EDGE : at > EDGE;
|
|
2323
2330
|
}
|
|
2324
|
-
/**
|
|
2325
|
-
* Where what a scroller shows is in sight down the screen, or across it along `x` (T94): within
|
|
2326
|
-
* the ancestors that clip it and the visual viewport, from `start` to `end` — and how much it
|
|
2327
|
-
* shows whole, for a scroller out of sight.
|
|
2328
|
-
*/
|
|
2329
|
-
function sightOf(target, axis) {
|
|
2330
|
-
const down = axis === "y";
|
|
2331
|
-
const sight = window.visualViewport;
|
|
2332
|
-
let start = (down ? sight?.offsetTop : sight?.offsetLeft) ?? 0;
|
|
2333
|
-
let end = start + ((down ? sight?.height : sight?.width) ?? (down ? innerHeight : innerWidth));
|
|
2334
|
-
let whole = end - start;
|
|
2335
|
-
if (target instanceof Element) {
|
|
2336
|
-
const own = clientBoxOf(target);
|
|
2337
|
-
whole = down ? own.bottom - own.top : own.right - own.left;
|
|
2338
|
-
// The scroller, and every ancestor that clips it, up to the page, whose part is the sight.
|
|
2339
|
-
for (let node = target; node !== null; node = parentOf(node)) {
|
|
2340
|
-
if (node === document.documentElement)
|
|
2341
|
-
break;
|
|
2342
|
-
const style = node === target ? undefined : getComputedStyle(node);
|
|
2343
|
-
if (style !== undefined && (down ? style.overflowY : style.overflowX) === "visible")
|
|
2344
|
-
continue;
|
|
2345
|
-
const clip = node === target ? own : clientBoxOf(node);
|
|
2346
|
-
start = Math.max(start, down ? clip.top : clip.left);
|
|
2347
|
-
end = Math.min(end, down ? clip.bottom : clip.right);
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
return { start, end, whole };
|
|
2351
|
-
}
|
|
2352
2331
|
/** Whether an element holds another in the flat tree, across the borders of shadow trees. */
|
|
2353
2332
|
function holds(ancestor, element) {
|
|
2354
2333
|
for (let node = parentOf(element); node !== null; node = parentOf(node)) {
|