@wardic/foldkit 0.0.0-stage → 1.2.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/LICENSE +21 -0
- package/README.md +59 -2
- package/THIRD_PARTY_NOTICES.md +145 -0
- package/dist/AnimationControls.d.ts +37 -0
- package/dist/AnimationControls.d.ts.map +1 -0
- package/dist/AnimationControls.js +37 -0
- package/dist/AnimationControls.js.map +1 -0
- package/dist/AnimationScope.d.ts +20 -0
- package/dist/AnimationScope.d.ts.map +1 -0
- package/dist/AnimationScope.js +20 -0
- package/dist/AnimationScope.js.map +1 -0
- package/dist/DragControls.d.ts +25 -0
- package/dist/DragControls.d.ts.map +1 -0
- package/dist/DragControls.js +21 -0
- package/dist/DragControls.js.map +1 -0
- package/dist/Features.d.ts +36 -0
- package/dist/Features.d.ts.map +1 -0
- package/dist/Features.js +44 -0
- package/dist/Features.js.map +1 -0
- package/dist/Ward.d.ts +301 -0
- package/dist/Ward.d.ts.map +1 -0
- package/dist/Ward.js +6 -0
- package/dist/Ward.js.map +1 -0
- package/dist/Wardic.d.ts +363 -0
- package/dist/Wardic.d.ts.map +1 -0
- package/dist/Wardic.js +85 -0
- package/dist/Wardic.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/builder.d.ts +8 -0
- package/dist/internal/builder.d.ts.map +1 -0
- package/dist/internal/builder.js +242 -0
- package/dist/internal/builder.js.map +1 -0
- package/dist/internal/commands.d.ts +143 -0
- package/dist/internal/commands.d.ts.map +1 -0
- package/dist/internal/commands.js +242 -0
- package/dist/internal/commands.js.map +1 -0
- package/dist/internal/delivery.d.ts +44 -0
- package/dist/internal/delivery.d.ts.map +1 -0
- package/dist/internal/delivery.js +85 -0
- package/dist/internal/delivery.js.map +1 -0
- package/dist/internal/dev.d.ts +10 -0
- package/dist/internal/dev.d.ts.map +1 -0
- package/dist/internal/dev.js +10 -0
- package/dist/internal/dev.js.map +1 -0
- package/dist/internal/dev.production.d.ts +8 -0
- package/dist/internal/dev.production.d.ts.map +1 -0
- package/dist/internal/dev.production.js +8 -0
- package/dist/internal/dev.production.js.map +1 -0
- package/dist/internal/drag.d.ts +66 -0
- package/dist/internal/drag.d.ts.map +1 -0
- package/dist/internal/drag.js +71 -0
- package/dist/internal/drag.js.map +1 -0
- package/dist/internal/element.d.ts +59 -0
- package/dist/internal/element.d.ts.map +1 -0
- package/dist/internal/element.js +582 -0
- package/dist/internal/element.js.map +1 -0
- package/dist/internal/gestures.d.ts +62 -0
- package/dist/internal/gestures.d.ts.map +1 -0
- package/dist/internal/gestures.js +109 -0
- package/dist/internal/gestures.js.map +1 -0
- package/dist/internal/hydrate.d.ts +5 -0
- package/dist/internal/hydrate.d.ts.map +1 -0
- package/dist/internal/hydrate.js +27 -0
- package/dist/internal/hydrate.js.map +1 -0
- package/dist/internal/keys.d.ts +21 -0
- package/dist/internal/keys.d.ts.map +1 -0
- package/dist/internal/keys.js +12 -0
- package/dist/internal/keys.js.map +1 -0
- package/dist/internal/layout.d.ts +29 -0
- package/dist/internal/layout.d.ts.map +1 -0
- package/dist/internal/layout.js +88 -0
- package/dist/internal/layout.js.map +1 -0
- package/dist/internal/mount.d.ts +22 -0
- package/dist/internal/mount.d.ts.map +1 -0
- package/dist/internal/mount.js +100 -0
- package/dist/internal/mount.js.map +1 -0
- package/dist/internal/presence.d.ts +33 -0
- package/dist/internal/presence.d.ts.map +1 -0
- package/dist/internal/presence.js +338 -0
- package/dist/internal/presence.js.map +1 -0
- package/dist/internal/reactivity.d.ts +15 -0
- package/dist/internal/reactivity.d.ts.map +1 -0
- package/dist/internal/reactivity.js +26 -0
- package/dist/internal/reactivity.js.map +1 -0
- package/dist/internal/reorder.d.ts +47 -0
- package/dist/internal/reorder.d.ts.map +1 -0
- package/dist/internal/reorder.js +250 -0
- package/dist/internal/reorder.js.map +1 -0
- package/dist/internal/scope.d.ts +28 -0
- package/dist/internal/scope.d.ts.map +1 -0
- package/dist/internal/scope.js +44 -0
- package/dist/internal/scope.js.map +1 -0
- package/dist/internal/server.d.ts +13 -0
- package/dist/internal/server.d.ts.map +1 -0
- package/dist/internal/server.js +13 -0
- package/dist/internal/server.js.map +1 -0
- package/dist/internal/server.node.d.ts +8 -0
- package/dist/internal/server.node.d.ts.map +1 -0
- package/dist/internal/server.node.js +8 -0
- package/dist/internal/server.node.js.map +1 -0
- package/dist/internal/services.d.ts +222 -0
- package/dist/internal/services.d.ts.map +1 -0
- package/dist/internal/services.js +338 -0
- package/dist/internal/services.js.map +1 -0
- package/dist/internal/tree.d.ts +71 -0
- package/dist/internal/tree.d.ts.map +1 -0
- package/dist/internal/tree.js +207 -0
- package/dist/internal/tree.js.map +1 -0
- package/dist/internal/variant-node.d.ts +62 -0
- package/dist/internal/variant-node.d.ts.map +1 -0
- package/dist/internal/variant-node.js +279 -0
- package/dist/internal/variant-node.js.map +1 -0
- package/dist/internal/view-transition.d.ts +10 -0
- package/dist/internal/view-transition.d.ts.map +1 -0
- package/dist/internal/view-transition.js +36 -0
- package/dist/internal/view-transition.js.map +1 -0
- package/dist/internal/walk.d.ts +26 -0
- package/dist/internal/walk.d.ts.map +1 -0
- package/dist/internal/walk.js +162 -0
- package/dist/internal/walk.js.map +1 -0
- package/package.json +99 -4
- package/src/AnimationControls.ts +46 -0
- package/src/AnimationScope.ts +19 -0
- package/src/DragControls.ts +27 -0
- package/src/Features.ts +45 -0
- package/src/Ward.ts +434 -0
- package/src/Wardic.ts +410 -0
- package/src/index.ts +20 -0
- package/src/internal/builder.ts +262 -0
- package/src/internal/commands.ts +359 -0
- package/src/internal/delivery.ts +116 -0
- package/src/internal/dev.production.ts +7 -0
- package/src/internal/dev.ts +9 -0
- package/src/internal/drag.ts +136 -0
- package/src/internal/element.ts +668 -0
- package/src/internal/gestures.ts +184 -0
- package/src/internal/hydrate.ts +29 -0
- package/src/internal/keys.ts +19 -0
- package/src/internal/layout.ts +109 -0
- package/src/internal/mount.ts +124 -0
- package/src/internal/presence.ts +362 -0
- package/src/internal/reactivity.ts +45 -0
- package/src/internal/reorder.ts +313 -0
- package/src/internal/scope.ts +60 -0
- package/src/internal/server.node.ts +7 -0
- package/src/internal/server.ts +12 -0
- package/src/internal/services.ts +486 -0
- package/src/internal/tree.ts +230 -0
- package/src/internal/variant-node.ts +352 -0
- package/src/internal/view-transition.ts +43 -0
- package/src/internal/walk.ts +211 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **Delivery** (ADR-0071, decision 20): how each render's config reaches a mounted element. A `w.*`
|
|
3
|
+
* element renders its folded config as one `wardic` property, minted by a `CustomElement.define`
|
|
4
|
+
* spec's property factory, the public way to a `Prop` attribute (P6). Foldkit's props module writes
|
|
5
|
+
* the property at `create` and again on each render whose value is a fresh reference, parent first.
|
|
6
|
+
* At mount, the element's Mount puts an accessor on the property, so each later write is a setter call
|
|
7
|
+
* inside the patch, where the element Retargets (#791, Q14).
|
|
8
|
+
*
|
|
9
|
+
* The patch's microtask (#791, Q25): the first setter call of a patch, or its first Mount insert,
|
|
10
|
+
* queues one microtask, which runs after the whole patch and before paint: the `Reactivity` port's
|
|
11
|
+
* watches re-read there (decision 17), then slice 1's PR 3 adds the held-frame hint.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type * as FrameLoop from "@wardic/core/FrameLoop"
|
|
16
|
+
import * as CustomElement from "foldkit/customElement"
|
|
17
|
+
import type { Attribute, HtmlBuilder } from "foldkit/html"
|
|
18
|
+
import * as Schema from "effect/Schema"
|
|
19
|
+
import * as Predicate from "effect/Predicate"
|
|
20
|
+
import * as UndefinedOr from "effect/UndefinedOr"
|
|
21
|
+
import { recheck } from "./reactivity.ts"
|
|
22
|
+
|
|
23
|
+
/** The property an element's config is delivered through. */
|
|
24
|
+
const KEY = "wardic"
|
|
25
|
+
|
|
26
|
+
// Schema, where Foldkit's API asks for it (ADR-0071, decision 14): a `CustomElement.define` spec types
|
|
27
|
+
// each property with one. Its value is never decoded: the config is Wardic's own, checked by hand.
|
|
28
|
+
/** The spec whose `Wardic` factory builds the `wardic` property attribute, for any element. */
|
|
29
|
+
const spec = /*#__PURE__*/ CustomElement.define({ tag: "wardic-element", properties: { [KEY]: Schema.Unknown }, events: {} })
|
|
30
|
+
|
|
31
|
+
/** The factory for `h`'s Message: `withMessage` is a type witness, minted once per builder. */
|
|
32
|
+
// Module state (#460, Q7): a cache keyed by the builder it's minted for.
|
|
33
|
+
const factories = new WeakMap<object, (value: unknown) => Attribute<never>>()
|
|
34
|
+
|
|
35
|
+
/** The `wardic` property attribute carrying `config`, for a view built with `h`. */
|
|
36
|
+
export const propertyOf = <Message>(h: HtmlBuilder<Message>, config: object): Attribute<Message> => {
|
|
37
|
+
let factory = factories.get(h)
|
|
38
|
+
if (Predicate.isUndefined(factory)) {
|
|
39
|
+
factory = spec.withMessage(h).Wardic as (value: unknown) => Attribute<never>
|
|
40
|
+
factories.set(h, factory)
|
|
41
|
+
}
|
|
42
|
+
return factory(config) as Attribute<Message>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** An element with its `wardic` property, as the props module writes it. */
|
|
46
|
+
interface Delivered {
|
|
47
|
+
[KEY]?: unknown
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The config last delivered to `element`: what the props module wrote at `create`, or a setter took since. */
|
|
51
|
+
export const deliveredTo = (element: Element): unknown => (element as Delivered)[KEY]
|
|
52
|
+
|
|
53
|
+
/** The config a view node carries for its element, before any delivery: its `wardic` property among `props` (#794's walk). */
|
|
54
|
+
export const carriedBy = (props: Record<string, unknown> | undefined): unknown => UndefinedOr.map(props, (given) => given[KEY])
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* An accessor for the `wardic` property on `element`, over the value the props module wrote at
|
|
58
|
+
* `create`: every later write calls `onSet`, inside the patch. Returns the release, which puts the
|
|
59
|
+
* plain property back with its last value.
|
|
60
|
+
*/
|
|
61
|
+
export const installSetter = (element: Element, onSet: (value: unknown) => void): (() => void) => {
|
|
62
|
+
const target = element as Delivered
|
|
63
|
+
let value = target[KEY]
|
|
64
|
+
Object.defineProperty(target, KEY, {
|
|
65
|
+
configurable: true,
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: () => value,
|
|
68
|
+
set: (next: unknown) => {
|
|
69
|
+
value = next
|
|
70
|
+
onSet(next)
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
return () => {
|
|
74
|
+
delete target[KEY]
|
|
75
|
+
target[KEY] = value
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Module state (#460, Q7): whether this patch's microtask is queued, cleared when it runs.
|
|
80
|
+
let queued = false
|
|
81
|
+
|
|
82
|
+
/** What the patch's microtask does: the watches, then (PR 3) the held-frame hint. */
|
|
83
|
+
const afterPatch = (): void => {
|
|
84
|
+
queued = false
|
|
85
|
+
recheck()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A patch touched the page: a setter call, or a Mount's insert. Queues the patch's microtask, once per
|
|
90
|
+
* patch, however many elements say so. A plain `queueMicrotask`: core's end-of-task checkpoint.
|
|
91
|
+
*/
|
|
92
|
+
export const patchTouched = (): void => {
|
|
93
|
+
if (queued) return
|
|
94
|
+
queued = true
|
|
95
|
+
queueMicrotask(afterPatch)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The frame's time, as every rAF callback of a frame sees it: what the hint compares the last tick's with. */
|
|
99
|
+
const frameTime = (): number => Number(document.timeline.currentTime)
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The binding's hint (ADR-0071, decision 32; #673's deferred rule): a setter runs inside Foldkit's
|
|
103
|
+
* patch, a Refresh frame callback after Wardic's tick, so the Frame loop opens its Late window for the
|
|
104
|
+
* Retargets the patch makes, and they paint in this frame rather than the next. Called before the
|
|
105
|
+
* Retarget, after {@link patchTouched}, so the window's microtask runs after the patch's. Not for a
|
|
106
|
+
* replay's patch, which runs in a task (P6): the time read there is a past frame's.
|
|
107
|
+
*/
|
|
108
|
+
export const hintFrame = (loop: FrameLoop.FrameLoop["Service"]): void => {
|
|
109
|
+
loop.hint(frameTime())
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The hint (above), unless DevTools replay has the view (decision 34), whose patch runs in a task and lands everything at once. */
|
|
113
|
+
export const hintFrameUnless = (loop: FrameLoop.FrameLoop["Service"], paused: () => boolean): void => {
|
|
114
|
+
if (paused()) return
|
|
115
|
+
hintFrame(loop)
|
|
116
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development: on. The package's `development` export condition resolves this module, as Solid's
|
|
3
|
+
* `DEV` is Solid's own condition (#791, Q10); a production build resolves `dev.production.ts`, so a
|
|
4
|
+
* check under `DEV` and what it calls are dropped from it. Tested in a plain `if` or `&&`, never through
|
|
5
|
+
* `Bool`, as a build-time flag is (`docs/agents/effect-first.md`, *Pitfalls*).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export const DEV = true
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `w.*` element's drag (#793, PR 2; ADR-0004; ADR-0071 decision 23): dom's drag track, driven by the
|
|
3
|
+
* binding (the `drag` Feature's `drive`), started the first time a delivery wants it (`w.Drag` while
|
|
4
|
+
* `Features.drag` is built) and kept, in a Scope of the element's own on the provider, closed at the
|
|
5
|
+
* release. Its options are read as it starts (Q6): a changed one wants a new key. Its defaults are
|
|
6
|
+
* written then (Q10; ADR-0019 *Amendment (Reorder)*), under the element's own inline style, and it
|
|
7
|
+
* drives the layout node the element has then (ADR-0016). What the spine reads of it (its axis, its
|
|
8
|
+
* track, whether it drives a projection) sits on the spine's options, written as the track starts: the
|
|
9
|
+
* spine reads each where it uses it. A drag wanted without its Feature is inert, and warned once in
|
|
10
|
+
* development.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type * as Drag from "@wardic/core/Drag"
|
|
15
|
+
import type * as InputFeed from "@wardic/core/InputFeed"
|
|
16
|
+
import type * as Spine from "@wardic/core/unstable/Spine"
|
|
17
|
+
import type * as Values from "@wardic/core/Values"
|
|
18
|
+
import type * as ProjectionSystem from "@wardic/dom/ProjectionSystem"
|
|
19
|
+
import * as DragDefaults from "@wardic/dom/unstable/DragDefaults"
|
|
20
|
+
import * as DragTrack from "@wardic/dom/unstable/DragTrack"
|
|
21
|
+
import * as DragTransition from "@wardic/dom/unstable/DragTransition"
|
|
22
|
+
import * as ElementSetup from "@wardic/dom/unstable/ElementSetup"
|
|
23
|
+
import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures"
|
|
24
|
+
import type * as LiveStyle from "@wardic/dom/unstable/LiveStyle"
|
|
25
|
+
import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
|
|
26
|
+
import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
|
|
27
|
+
import * as Keys from "@wardic/dom/unstable/features/Keys"
|
|
28
|
+
import * as MutableRef from "effect/MutableRef"
|
|
29
|
+
import * as Predicate from "effect/Predicate"
|
|
30
|
+
import * as Scope from "effect/Scope"
|
|
31
|
+
import * as UndefinedOr from "effect/UndefinedOr"
|
|
32
|
+
import type { View } from "./element.ts"
|
|
33
|
+
import { featureIn, type Provider, reporterOf, warnMissing } from "./services.ts"
|
|
34
|
+
|
|
35
|
+
/** What the spine reads of an element's drag (ADR-0004, #340): on its options, written as the track starts. */
|
|
36
|
+
export interface SpineDragOptions {
|
|
37
|
+
dragAxis: boolean | "x" | "y" | undefined
|
|
38
|
+
drag: Spine.SpineDrag | undefined
|
|
39
|
+
projected: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** What an element's drag is made with. */
|
|
43
|
+
export interface DragOptions {
|
|
44
|
+
readonly provider: Provider
|
|
45
|
+
readonly element: HTMLElement
|
|
46
|
+
/** The element's id, for a report. */
|
|
47
|
+
readonly id: string
|
|
48
|
+
/** The element's config now, as its last delivery gave it: the drag's options read as the track starts, the measure's function at each measure. */
|
|
49
|
+
readonly config: () => Pick<View, "drag" | "dragListener" | "dragConstraints" | "dragControls" | "onMeasureDragConstraints" | keyof DragTrack.DragOptions | "dragTransition">
|
|
50
|
+
/** The spine's Snapshot, which the drag reads and writes `x`/`y` through. */
|
|
51
|
+
readonly snapshot: Spine.Snapshot
|
|
52
|
+
readonly recordFrame: (value: Values.Values) => void
|
|
53
|
+
readonly live: LiveStyle.LiveStyle
|
|
54
|
+
/** The element's spine options: what the spine reads of the drag. */
|
|
55
|
+
readonly spine: SpineDragOptions
|
|
56
|
+
/** The element's layout node now: the track's projection as it starts (ADR-0016). */
|
|
57
|
+
readonly layoutNode: () => ProjectionSystem.DragHandle | undefined
|
|
58
|
+
/** A Reorder item's axis, read at each gesture's start in place of `Drag`'s (ADR-0020): the group's, once the item has joined it; `undefined` for any other element. Read as the track starts. */
|
|
59
|
+
readonly itemAxis: () => (() => true | "x" | "y") | undefined
|
|
60
|
+
/** The nearest `w.Config`'s `transformPagePoint` (Q9), read at each down. */
|
|
61
|
+
readonly pagePoint: () => WardConfig.WardicTransformPoint | undefined
|
|
62
|
+
readonly skipAnimations: () => boolean
|
|
63
|
+
/** Told as the drag takes `x`/`y`, and as it hands them back. */
|
|
64
|
+
readonly onDragging: (on: boolean) => void
|
|
65
|
+
/** Each sample, after the track's write: the element's drag callbacks. */
|
|
66
|
+
readonly onSample: (sample: Drag.Sample) => void
|
|
67
|
+
/** The release came to rest on its own. */
|
|
68
|
+
readonly onReleaseEnd: () => void
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** An element's drag (above). */
|
|
72
|
+
export interface ElementDrag {
|
|
73
|
+
/** Start the track if the config wants it and the Feature is here, once: at mount, at each delivery, and as a Feature arrives. */
|
|
74
|
+
readonly check: () => void
|
|
75
|
+
/** Close the track's Scope: at the element's release. */
|
|
76
|
+
readonly dispose: () => void
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The track's end that failed, at the element's release. */
|
|
80
|
+
const END_FAILED = "wardic.drag: the track's end failed"
|
|
81
|
+
|
|
82
|
+
/** A watch's own handler threw, dom's, past the app's callbacks. */
|
|
83
|
+
const WATCH_FAILED = "wardic.drag: a watch's handler failed"
|
|
84
|
+
|
|
85
|
+
/** An element's drag (above): nothing started until `check` wants it. */
|
|
86
|
+
export const dragOf = (opts: DragOptions): ElementDrag => {
|
|
87
|
+
const { provider, element, id, spine, config } = opts
|
|
88
|
+
const scope = MutableRef.make<Scope.Closeable | undefined>(undefined)
|
|
89
|
+
const report = reporterOf(provider, id)
|
|
90
|
+
const onDefect: InputFeed.OnDefect = (cause) => report(WATCH_FAILED, cause)
|
|
91
|
+
/** The track, from this delivery's options: its defaults written first, its Scope the element's own. */
|
|
92
|
+
const start = (service: Keys.DragGesture["Service"], axis: boolean | "x" | "y", axisAt: (() => true | "x" | "y") | undefined): void => {
|
|
93
|
+
const c = config()
|
|
94
|
+
UndefinedOr.map(DragDefaults.dragDefaultsOf(c, { dragAxis: axisAt }), (defaults) => DragDefaults.applyDragDefaults(element, defaults))
|
|
95
|
+
const constraints = service.constraintsOf(c.dragConstraints, element, () => config().onMeasureDragConstraints, opts.pagePoint)
|
|
96
|
+
const projection = opts.layoutNode()
|
|
97
|
+
const owner = OwnerScope.open(provider.runtime)
|
|
98
|
+
MutableRef.set(scope, owner)
|
|
99
|
+
const track = service.drive({
|
|
100
|
+
watch: (track) => provider.runtime.runSync(track(onDefect).pipe(Scope.provide(owner))),
|
|
101
|
+
fork: (response) => void provider.runtime.runFork(response),
|
|
102
|
+
gate: provider.gate,
|
|
103
|
+
id,
|
|
104
|
+
element,
|
|
105
|
+
snapshot: opts.snapshot,
|
|
106
|
+
recordFrame: opts.recordFrame,
|
|
107
|
+
// A drag's start turns its `style`'s will-change value on (#443).
|
|
108
|
+
setDragging: ElementSetup.draggingWithWillChange(opts.live, opts.onDragging, element),
|
|
109
|
+
claim: ElementSetup.claimForDrag(element),
|
|
110
|
+
config: DragTrack.trackConfigOf(c, axis, constraints.constraints, DragTransition.dragTransitionOf(c.dragElastic, c.dragTransition)),
|
|
111
|
+
// A drag on a layout node feeds the projection (ADR-0016): it follows the pointer and FLIPs to its slot on release.
|
|
112
|
+
projection,
|
|
113
|
+
axisAt,
|
|
114
|
+
onSample: opts.onSample,
|
|
115
|
+
onReleaseEnd: opts.onReleaseEnd,
|
|
116
|
+
skipAnimations: opts.skipAnimations,
|
|
117
|
+
container: constraints.container,
|
|
118
|
+
controls: c.dragControls,
|
|
119
|
+
mapPoint: opts.pagePoint,
|
|
120
|
+
})
|
|
121
|
+
spine.dragAxis = axis
|
|
122
|
+
spine.drag = track
|
|
123
|
+
spine.projected = Predicate.isNotUndefined(projection)
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
check: () => {
|
|
127
|
+
if (Predicate.isNotUndefined(MutableRef.get(scope))) return
|
|
128
|
+
// A Reorder item drags on its group's axis, read at each gesture's start: `true` to the spine (ADR-0020).
|
|
129
|
+
const axisAt = opts.itemAxis()
|
|
130
|
+
const axis = DragDefaults.dragAxisOf(config(), { dragAxis: axisAt })
|
|
131
|
+
if (Predicate.isUndefined(axis)) return
|
|
132
|
+
UndefinedOr.match(featureIn(provider, Keys.DragGesture), { onUndefined: () => warnMissing(provider, "drag", GestureFeatures.GESTURE_WORDS.drag), onDefined: (service) => start(service, axis, axisAt) })
|
|
133
|
+
},
|
|
134
|
+
dispose: () => UndefinedOr.map(MutableRef.get(scope), (owner) => OwnerScope.close(provider.runtime, owner, END_FAILED)),
|
|
135
|
+
}
|
|
136
|
+
}
|