@wardic/dom 1.0.0-rc.8 → 1.0.0
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/Appear.d.ts +7 -1
- package/dist/Appear.d.ts.map +1 -1
- package/dist/Appear.js +7 -1
- package/dist/Appear.js.map +1 -1
- package/dist/DomBatch.d.ts +20 -0
- package/dist/DomBatch.d.ts.map +1 -0
- package/dist/DomBatch.js +23 -0
- package/dist/DomBatch.js.map +1 -0
- package/dist/DomInput.d.ts +2 -1
- package/dist/DomInput.d.ts.map +1 -1
- package/dist/DomInput.js +3 -1
- package/dist/DomInput.js.map +1 -1
- package/dist/KeyboardPress.d.ts +16 -0
- package/dist/KeyboardPress.d.ts.map +1 -0
- package/dist/KeyboardPress.js +17 -0
- package/dist/KeyboardPress.js.map +1 -0
- package/dist/ReorderController.d.ts +24 -4
- package/dist/ReorderController.d.ts.map +1 -1
- package/dist/ReorderController.js +38 -4
- package/dist/ReorderController.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/appear-slot.d.ts +23 -0
- package/dist/internal/appear-slot.d.ts.map +1 -0
- package/dist/internal/appear-slot.js +29 -0
- package/dist/internal/appear-slot.js.map +1 -0
- package/dist/internal/appear.d.ts +84 -16
- package/dist/internal/appear.d.ts.map +1 -1
- package/dist/internal/appear.js +302 -61
- package/dist/internal/appear.js.map +1 -1
- package/dist/internal/batch-writer.d.ts +16 -0
- package/dist/internal/batch-writer.d.ts.map +1 -0
- package/dist/internal/batch-writer.js +77 -0
- package/dist/internal/batch-writer.js.map +1 -0
- package/dist/internal/gate.d.ts +3 -2
- package/dist/internal/gate.d.ts.map +1 -1
- package/dist/internal/gate.js +5 -1
- package/dist/internal/gate.js.map +1 -1
- package/dist/internal/input.d.ts +0 -6
- package/dist/internal/input.d.ts.map +1 -1
- package/dist/internal/input.js +205 -23
- package/dist/internal/input.js.map +1 -1
- package/dist/internal/keyboard-press.d.ts +7 -0
- package/dist/internal/keyboard-press.d.ts.map +1 -0
- package/dist/internal/keyboard-press.js +45 -0
- package/dist/internal/keyboard-press.js.map +1 -0
- package/dist/internal/measure.d.ts +7 -0
- package/dist/internal/measure.d.ts.map +1 -1
- package/dist/internal/measure.js +19 -1
- package/dist/internal/measure.js.map +1 -1
- package/dist/internal/projection.d.ts +13 -5
- package/dist/internal/projection.d.ts.map +1 -1
- package/dist/internal/projection.js +271 -33
- package/dist/internal/projection.js.map +1 -1
- package/dist/internal/renderer.d.ts +18 -0
- package/dist/internal/renderer.d.ts.map +1 -1
- package/dist/internal/renderer.js +4 -2
- package/dist/internal/renderer.js.map +1 -1
- package/dist/internal/reorder.d.ts +28 -13
- package/dist/internal/reorder.d.ts.map +1 -1
- package/dist/internal/reorder.js +55 -26
- package/dist/internal/reorder.js.map +1 -1
- package/dist/internal/reveal.d.ts +7 -3
- package/dist/internal/reveal.d.ts.map +1 -1
- package/dist/internal/reveal.js +8 -3
- package/dist/internal/reveal.js.map +1 -1
- package/package.json +4 -4
- package/src/Appear.ts +12 -3
- package/src/DomBatch.ts +22 -0
- package/src/DomInput.ts +2 -1
- package/src/KeyboardPress.ts +16 -0
- package/src/ReorderController.ts +54 -4
- package/src/index.ts +5 -3
- package/src/internal/appear-slot.ts +32 -0
- package/src/internal/appear.ts +462 -67
- package/src/internal/batch-writer.ts +95 -0
- package/src/internal/gate.ts +7 -3
- package/src/internal/input.ts +209 -25
- package/src/internal/keyboard-press.ts +45 -0
- package/src/internal/measure.ts +17 -1
- package/src/internal/projection.ts +272 -38
- package/src/internal/renderer.ts +4 -2
- package/src/internal/reorder.ts +85 -39
- package/src/internal/reveal.ts +10 -4
package/src/internal/reorder.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* and routes each item's drag samples: the start opens the group's gesture, each move
|
|
9
9
|
* runs the Crossover and Auto-scroll, the end (or the item's disposal mid-gesture)
|
|
10
10
|
* closes both. The items' `touch-action` needs the axis before a touch starts, so after
|
|
11
|
-
*
|
|
11
|
+
* the items are laid out (a Measure pass, or a placed group's placing) the controller detects the axis from the items' boxes and reports
|
|
12
12
|
* a change through `onAxis`; while the app sets the axis it detects nothing. Motion
|
|
13
13
|
* detects on every item's every measurement (Group.tsx:121-133 at 16c6122). When the app
|
|
14
14
|
* clears its axis, no Measure pass comes with that: a binding reads `detect()`, the axis
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* itself that the page didn't take (Space or Enter lifts and drops, Escape cancels, the arrows,
|
|
21
21
|
* Home and End move the lifted item) goes to core's `Reorder` model, its default prevented; each
|
|
22
22
|
* step is an **Announcement** (a held arrow's thinned to the last), scrolls the item's new place
|
|
23
|
-
* into view
|
|
23
|
+
* into view once the items are laid out again, and keeps focus on the item; the lifted node is
|
|
24
24
|
* raised as a dragged one is, and the binding turns its `whileDrag` on. Focus leaving the item, a
|
|
25
25
|
* press on it, or the app changing `values` drops it where it is; its unmount ends the lift unsaid.
|
|
26
26
|
*
|
|
@@ -40,11 +40,13 @@ import * as AutoScroll from "@wardic/core/AutoScroll"
|
|
|
40
40
|
import type * as Drag from "@wardic/core/Drag"
|
|
41
41
|
import type * as InputSource from "@wardic/core/InputSource"
|
|
42
42
|
import * as Reorder from "@wardic/core/Reorder"
|
|
43
|
+
import * as Arr from "effect/Array"
|
|
43
44
|
import * as Bool from "effect/Boolean"
|
|
44
45
|
import * as Duration from "effect/Duration"
|
|
45
46
|
import * as Effect from "effect/Effect"
|
|
47
|
+
import * as Equivalence from "effect/Equivalence"
|
|
46
48
|
import * as FiberHandle from "effect/FiberHandle"
|
|
47
|
-
import { constTrue, constVoid, identity } from "effect/Function"
|
|
49
|
+
import { constFalse, constTrue, constVoid, identity } from "effect/Function"
|
|
48
50
|
import * as Match from "effect/Match"
|
|
49
51
|
import * as MutableRef from "effect/MutableRef"
|
|
50
52
|
import * as Option from "effect/Option"
|
|
@@ -54,9 +56,8 @@ import * as Str from "effect/String"
|
|
|
54
56
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
55
57
|
import { documentOf, prepareAnnouncer } from "./announcer.ts"
|
|
56
58
|
import { type AutoScroller, makeAutoScroller } from "./auto-scroll.ts"
|
|
57
|
-
import type { ProjectionNodeHandle, ProjectionSystem } from "./projection.ts"
|
|
58
59
|
import { debugOf } from "./report.ts"
|
|
59
|
-
import { revealLayoutOf } from "./reveal.ts"
|
|
60
|
+
import { type Rect, revealLayoutOf, revealRectOf } from "./reveal.ts"
|
|
60
61
|
import type { Runner } from "./runner.ts"
|
|
61
62
|
|
|
62
63
|
/**
|
|
@@ -67,19 +68,36 @@ import type { Runner } from "./runner.ts"
|
|
|
67
68
|
export const REORDER_GROUP_STYLE = Object.freeze({ "overflow-anchor": "none" } as const)
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
|
-
* What {@link makeReorderController} runs on: the runner it logs through,
|
|
71
|
-
*
|
|
72
|
-
* its
|
|
71
|
+
* What {@link makeReorderController} runs on: the runner it logs through, how its items are laid out
|
|
72
|
+
* again and when they have been, and the Environment's `Announcer`. `ReorderController.make` wires
|
|
73
|
+
* them to the projection system its items are nodes of (#132's PR 3, ADR-0041); `makePlaced` to a
|
|
74
|
+
* binding that places its items itself, a Batch Reorder group's (#712, ADR-0072).
|
|
73
75
|
*/
|
|
74
76
|
export interface ReorderControllerWiring {
|
|
75
77
|
/** The runner the controller logs through and waits in. */
|
|
76
78
|
readonly runtime: Runner<never>
|
|
77
|
-
/** The
|
|
78
|
-
readonly
|
|
79
|
+
/** The app changed `values`: have the items laid out in it, a Measure pass, or nothing for items the binding places itself. */
|
|
80
|
+
readonly layOut: () => void
|
|
79
81
|
/** Speak an **Announcement**: the Environment's `Announcer`. Left out, nothing is announced. */
|
|
80
82
|
readonly announce?: ((message: string) => void) | undefined
|
|
81
|
-
/**
|
|
82
|
-
readonly
|
|
83
|
+
/** Hears each time the items have been laid out: a Measure pass's end (the engine's `PassEnds`), or the binding's placing. */
|
|
84
|
+
readonly onLaidOut: (listener: () => void) => () => void
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* What an item registers with its group: core's `ItemSource` (its box, its drag offset, its box's
|
|
89
|
+
* version), how to raise it over the rest while it's lifted, and, for an item placed rather than
|
|
90
|
+
* measured, its place on screen, for a keyboard step's reveal. A projection handle is one.
|
|
91
|
+
*/
|
|
92
|
+
// #712: structural, so a Batch Reorder group's member registers as a layout node does.
|
|
93
|
+
export interface ReorderItemHandle extends Reorder.ItemSource {
|
|
94
|
+
/** Raise the item over the rest, or let it down: a keyboard lift's. */
|
|
95
|
+
readonly setLifted: (lifted: boolean) => void
|
|
96
|
+
/**
|
|
97
|
+
* Its place on screen, in client coordinates, which a keyboard step reveals once the items are laid
|
|
98
|
+
* out. Left out, its painted box with its own transform undone, a layout node's.
|
|
99
|
+
*/
|
|
100
|
+
readonly placeOnScreen?: (() => Rect) | undefined
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
/**
|
|
@@ -147,7 +165,7 @@ export interface ReorderControllerOptions<V> {
|
|
|
147
165
|
readonly onHoldEnd?: ((end: ReorderHoldEnd<V>) => void) | undefined
|
|
148
166
|
/** The app's axis, overriding detection; `None` to detect. */
|
|
149
167
|
readonly axis?: (() => Option.Option<Reorder.Axis>) | undefined
|
|
150
|
-
/** Called when the detected axis changes (
|
|
168
|
+
/** Called when the detected axis changes (once the items are laid out, or {@link ReorderController.resolve}). */
|
|
151
169
|
readonly onAxis?: ((axis: Reorder.Axis) => void) | undefined
|
|
152
170
|
/**
|
|
153
171
|
* How the binding keys its items, for the warning logged once per controller when an
|
|
@@ -166,8 +184,8 @@ export interface ReorderControllerOptions<V> {
|
|
|
166
184
|
|
|
167
185
|
/** One item of a {@link ReorderController}: its binding feeds it the item's handle, drag samples, keys, focus and presses. */
|
|
168
186
|
export interface ReorderItemDriver {
|
|
169
|
-
/** Register the item's projection
|
|
170
|
-
readonly register: (handle:
|
|
187
|
+
/** Register the item's handle, a projection node's or a placed item's, with the group; returns the unregister. */
|
|
188
|
+
readonly register: (handle: ReorderItemHandle) => () => void
|
|
171
189
|
/** The axis the item's drag takes, read at each gesture's start. */
|
|
172
190
|
readonly dragAxis: () => Reorder.Axis
|
|
173
191
|
/** The item's drag samples, as the drag delivers them. */
|
|
@@ -232,15 +250,15 @@ export interface ReorderController<V> {
|
|
|
232
250
|
*/
|
|
233
251
|
// #257's audit.
|
|
234
252
|
readonly detect: () => Reorder.Axis
|
|
235
|
-
/** The app's values changed:
|
|
253
|
+
/** The app's values changed: its items laid out in them (a Measure pass), so they animate to their new places. */
|
|
236
254
|
readonly valuesChanged: () => void
|
|
237
|
-
/** Stops listening
|
|
255
|
+
/** Stops listening for the items' layouts and ends the auto-scroll. The Scope calls it. */
|
|
238
256
|
readonly dispose: () => void
|
|
239
257
|
}
|
|
240
258
|
|
|
241
259
|
/** Build a {@link ReorderController}: a **Reorder group** over `wiring.projection`'s nodes. */
|
|
242
260
|
export const makeReorderController = <V>(wiring: ReorderControllerWiring, options: ReorderControllerOptions<V>): ReorderController<V> => {
|
|
243
|
-
const { runtime,
|
|
261
|
+
const { runtime, announce } = wiring
|
|
244
262
|
const debug = debugOf(runtime, "wardic.reorder")
|
|
245
263
|
// Speak an Announcement, or nothing without an `announce`.
|
|
246
264
|
const speak = UndefinedOr.match(announce, { onUndefined: () => constVoid, onDefined: identity })
|
|
@@ -259,7 +277,8 @@ export const makeReorderController = <V>(wiring: ReorderControllerWiring, option
|
|
|
259
277
|
const group = Reorder.make<V>({
|
|
260
278
|
values: options.values,
|
|
261
279
|
onReorder: (values) => {
|
|
262
|
-
|
|
280
|
+
// A copy of what it hands on: an app that keeps that array, a store's own, may change it in place (#721).
|
|
281
|
+
asked = Arr.copy(values)
|
|
263
282
|
options.onReorder(values)
|
|
264
283
|
},
|
|
265
284
|
axis: () => appAxis(),
|
|
@@ -286,12 +305,13 @@ export const makeReorderController = <V>(wiring: ReorderControllerWiring, option
|
|
|
286
305
|
/** The lifted item's element, its handle and its `onLift`, by value, while it's registered. */
|
|
287
306
|
interface Keyed {
|
|
288
307
|
readonly element: () => Option.Option<Element>
|
|
289
|
-
handle: Option.Option<
|
|
308
|
+
handle: Option.Option<ReorderItemHandle>
|
|
290
309
|
readonly onLift: (lifted: boolean) => void
|
|
291
310
|
}
|
|
292
311
|
const keyed = new Map<V, Keyed>()
|
|
293
|
-
const
|
|
294
|
-
|
|
312
|
+
const keyedOf = (value: V): Option.Option<Keyed> => Option.fromUndefinedOr(keyed.get(value))
|
|
313
|
+
const elementOf = (value: V): Option.Option<Element> => Option.flatMap(keyedOf(value), (k) => k.element())
|
|
314
|
+
// The item whose new place the next layout lays out, to scroll into view then.
|
|
295
315
|
const reveal = MutableRef.make(Option.none<V>())
|
|
296
316
|
// A held arrow's latest announcement, waiting for the next repeat (ADR-0025, *Amendment (#69)*): a
|
|
297
317
|
// fiber in the Scope the controller was built in, which closes it after `dispose`.
|
|
@@ -416,12 +436,12 @@ export const makeReorderController = <V>(wiring: ReorderControllerWiring, option
|
|
|
416
436
|
Match.tag("Cancel", () => {
|
|
417
437
|
if (Bool.not(lifted)) return
|
|
418
438
|
event.handle()
|
|
419
|
-
|
|
439
|
+
const placement = withReveal(value, () => Reorder.cancel(group, value))
|
|
440
|
+
Option.match(placement, {
|
|
420
441
|
onNone: constVoid,
|
|
421
442
|
onSome: (placement) => {
|
|
422
443
|
setLifted(value, false)
|
|
423
444
|
keepFocus(value)
|
|
424
|
-
if (placement.moved) MutableRef.set(reveal, Option.some(value))
|
|
425
445
|
announceNow(say("cancel", value, placement))
|
|
426
446
|
holdEnd(value, "cancel")
|
|
427
447
|
},
|
|
@@ -434,34 +454,52 @@ export const makeReorderController = <V>(wiring: ReorderControllerWiring, option
|
|
|
434
454
|
),
|
|
435
455
|
})
|
|
436
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* `reorder`'s placement, `value`'s new place to be revealed once its items are laid out when it moved.
|
|
459
|
+
* Asked before the reorder: a binding that places its items as `onReorder` sets them (`makePlaced`'s, a
|
|
460
|
+
* Batch Reorder group's, #712) says they're laid out before the reorder returns. Moving nothing, the
|
|
461
|
+
* ask is taken back.
|
|
462
|
+
*/
|
|
463
|
+
const withReveal = (value: V, reorder: () => Option.Option<Reorder.Placement>): Option.Option<Reorder.Placement> => {
|
|
464
|
+
const before = MutableRef.get(reveal)
|
|
465
|
+
MutableRef.set(reveal, Option.some(value))
|
|
466
|
+
const placement = reorder()
|
|
467
|
+
const moved = Option.exists(placement, (p) => p.moved)
|
|
468
|
+
// Laid out within it, its reveal was taken: nothing to take back.
|
|
469
|
+
if (Bool.and(Bool.not(moved), Option.contains(MutableRef.get(reveal), value))) MutableRef.set(reveal, before)
|
|
470
|
+
return placement
|
|
471
|
+
}
|
|
437
472
|
/** An arrow, Home or End: the lifted item's step, its announcement (a held arrow's thinned), its reveal. */
|
|
438
473
|
const stepLifted = (event: InputSource.KeyboardLikeEvent, value: V, lifted: boolean, intent: Extract<Reorder.KeyIntent, { readonly _tag: "Step" | "End" }>): void => {
|
|
439
474
|
// Not lifted, the arrows, Home and End keep their own work (scrolling the page).
|
|
440
475
|
if (Bool.not(lifted)) return
|
|
441
476
|
event.handle()
|
|
442
|
-
Option.match(Reorder.moveLifted(group, value, intent), {
|
|
477
|
+
Option.match(withReveal(value, () => Reorder.moveLifted(group, value, intent)), {
|
|
443
478
|
onNone: constVoid,
|
|
444
479
|
onSome: (placement) => {
|
|
445
|
-
// A repeat before the last step
|
|
480
|
+
// A repeat before the last step was laid out moved nothing: nothing to say.
|
|
446
481
|
if (placement.waiting) return
|
|
447
|
-
if (placement.moved)
|
|
448
|
-
MutableRef.set(reveal, Option.some(value))
|
|
449
|
-
keepFocus(value)
|
|
450
|
-
}
|
|
482
|
+
if (placement.moved) keepFocus(value)
|
|
451
483
|
const message = say("step", value, placement)
|
|
452
484
|
Bool.match(event.repeat, { onTrue: () => announceLater(message), onFalse: () => announceNow(message) })
|
|
453
485
|
},
|
|
454
486
|
})
|
|
455
487
|
}
|
|
456
488
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
489
|
+
/** `value`'s element in view, connected: by its place on screen when its handle gives one, else by its layout box. */
|
|
490
|
+
const revealOf = (value: V): void => {
|
|
491
|
+
const el = Option.filter(elementOf(value), (e) => e.isConnected)
|
|
492
|
+
if (Option.isNone(el)) return
|
|
493
|
+
const place = Option.flatMap(Option.flatMap(keyedOf(value), (k) => k.handle), (handle) => Option.fromUndefinedOr(handle.placeOnScreen))
|
|
494
|
+
Option.match(place, { onNone: () => revealLayoutOf(el.value), onSome: (placeOf) => revealRectOf(el.value, placeOf()) })
|
|
495
|
+
}
|
|
496
|
+
// Every Measure pass measures every node, and a binding that places its items says when it has: either
|
|
497
|
+
// way the items are laid out, and a stepped item's new place with them.
|
|
498
|
+
const stopLaidOut = wiring.onLaidOut(() => {
|
|
460
499
|
resolve()
|
|
461
500
|
const stepped = MutableRef.get(reveal)
|
|
462
501
|
MutableRef.set(reveal, Option.none())
|
|
463
|
-
|
|
464
|
-
if (Option.isSome(el)) revealLayoutOf(el.value)
|
|
502
|
+
if (Option.isSome(stepped)) revealOf(stepped.value)
|
|
465
503
|
})
|
|
466
504
|
|
|
467
505
|
const keyedWith = UndefinedOr.match(options.keyedWith, { onUndefined: () => "their value", onDefined: identity })
|
|
@@ -570,12 +608,13 @@ export const makeReorderController = <V>(wiring: ReorderControllerWiring, option
|
|
|
570
608
|
}),
|
|
571
609
|
detect: () => Reorder.resolveAxis(group),
|
|
572
610
|
valuesChanged: () => {
|
|
573
|
-
// The app changed `values` itself while an item is lifted: it's dropped at its new place.
|
|
574
|
-
|
|
575
|
-
|
|
611
|
+
// The app changed `values` itself while an item is lifted: it's dropped at its new place. The group's
|
|
612
|
+
// own order is told by its items, not its array: a binding reads a store's order as a new one (#721).
|
|
613
|
+
if (Option.isSome(Reorder.liftedValue(group)) && Bool.not(isAsked(asked, options.values()))) dropLifted()
|
|
614
|
+
wiring.layOut()
|
|
576
615
|
},
|
|
577
616
|
dispose: () => {
|
|
578
|
-
|
|
617
|
+
stopLaidOut()
|
|
579
618
|
resetAutoScroll()
|
|
580
619
|
},
|
|
581
620
|
}
|
|
@@ -583,6 +622,13 @@ export const makeReorderController = <V>(wiring: ReorderControllerWiring, option
|
|
|
583
622
|
|
|
584
623
|
const noop = (): void => {}
|
|
585
624
|
|
|
625
|
+
/** Whether two orders hold the same items in the same order. */
|
|
626
|
+
const sameOrder: Equivalence.Equivalence<ReadonlyArray<unknown>> = Arr.makeEquivalence(Equivalence.strictEqual())
|
|
627
|
+
|
|
628
|
+
/** Whether `values` is the order the group last asked for (ADR-0037, *Amendment (#721)*): its items, in its order. */
|
|
629
|
+
const isAsked = (asked: ReadonlyArray<unknown> | undefined, values: ReadonlyArray<unknown>): boolean =>
|
|
630
|
+
UndefinedOr.match(asked, { onUndefined: constFalse, onDefined: (order) => sameOrder(order, values) })
|
|
631
|
+
|
|
586
632
|
/**
|
|
587
633
|
* A {@link ReorderController} for a server render (ADR-0021), where there's no projection
|
|
588
634
|
* system to drive and nothing to reorder: its group has no values, so every operation on it
|
package/src/internal/reveal.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { scrollersOf } from "./scrollers.ts"
|
|
|
12
12
|
import * as Arr from "effect/Array"
|
|
13
13
|
|
|
14
14
|
/** A box on screen, in client coordinates. */
|
|
15
|
-
interface Rect {
|
|
15
|
+
export interface Rect {
|
|
16
16
|
readonly left: number
|
|
17
17
|
readonly top: number
|
|
18
18
|
readonly right: number
|
|
@@ -46,11 +46,17 @@ const scrollToShow = (min: number, max: number, viewMin: number, viewMax: number
|
|
|
46
46
|
return 0
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
/** Scroll `el`'s new place into view (see the module doc). */
|
|
50
|
-
export const revealLayoutOf = (el: Element): void =>
|
|
49
|
+
/** Scroll `el`'s new place into view (see the module doc): its layout box, its own transform undone. */
|
|
50
|
+
export const revealLayoutOf = (el: Element): void => revealRectOf(el, layoutRectOf(el))
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Scroll `place`, `el`'s place on screen, into view in each scroller around `el` and then the page: a
|
|
54
|
+
* placed item's (#712), whose place is computed, not where it's drawn.
|
|
55
|
+
*/
|
|
56
|
+
export const revealRectOf = (el: Element, place: Rect): void => {
|
|
51
57
|
const { ancestors, page } = scrollersOf(el)
|
|
52
58
|
// Each scroller in turn, nearest first: what it scrolls moves the element for the next.
|
|
53
|
-
const rect = Arr.reduce(ancestors,
|
|
59
|
+
const rect = Arr.reduce(ancestors, place, (rect, scroller) => {
|
|
54
60
|
const box = scroller.getBoundingClientRect()
|
|
55
61
|
const top = box.top + scroller.clientTop
|
|
56
62
|
const left = box.left + scroller.clientLeft
|