@tremolo-ui/dom 0.8.0 → 0.9.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/index.cjs +76 -1391
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -808
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +71 -808
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -1337
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +530 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +365 -0
- package/dist/internal.d.cts.map +1 -0
- package/dist/internal.d.ts +365 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +500 -0
- package/dist/internal.js.map +1 -0
- package/dist/marks-DK7xJmGM.d.cts +305 -0
- package/dist/marks-DK7xJmGM.d.cts.map +1 -0
- package/dist/marks-DK7xJmGM.d.ts +305 -0
- package/dist/marks-DK7xJmGM.d.ts.map +1 -0
- package/dist/xy-5Oc6JeJr.cjs +952 -0
- package/dist/xy-5Oc6JeJr.cjs.map +1 -0
- package/dist/xy-lNFl1CTO.js +827 -0
- package/dist/xy-lNFl1CTO.js.map +1 -0
- package/package.json +12 -2
- package/src/canvas/animation.ts +8 -0
- package/src/canvas/context.ts +0 -5
- package/src/index.ts +14 -77
- package/src/input/change-gesture.ts +104 -0
- package/src/internal.ts +51 -0
- package/src/midi/access.ts +16 -15
- package/src/midi/input.ts +2 -9
- package/src/number-input/stepper-drag.ts +9 -1
- package/src/pointer/drag-value.ts +3 -1
- package/src/pointer/wheel.ts +10 -7
- package/src/points-editor/index.ts +7 -1
package/src/pointer/wheel.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export interface WheelOptions {
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Called for every wheel event that `requireFocus` lets through. The
|
|
4
|
+
* listener is not passive, so this may call `preventDefault()` to keep the
|
|
5
|
+
* page from scrolling.
|
|
6
|
+
*/
|
|
7
|
+
onWheel: (event: WheelEvent) => void
|
|
4
8
|
/**
|
|
5
9
|
* Only report events while the focus is inside the element.
|
|
6
10
|
*
|
|
@@ -19,7 +23,7 @@ export interface WheelOptions {
|
|
|
19
23
|
|
|
20
24
|
export interface WheelInstance {
|
|
21
25
|
/** Replace the given options, keeping the listener in place. */
|
|
22
|
-
update: (options: WheelOptions) => void
|
|
26
|
+
update: (options: Partial<WheelOptions>) => void
|
|
23
27
|
destroy: () => void
|
|
24
28
|
}
|
|
25
29
|
|
|
@@ -31,10 +35,9 @@ export interface WheelInstance {
|
|
|
31
35
|
*/
|
|
32
36
|
export function createWheel(
|
|
33
37
|
element: Element,
|
|
34
|
-
|
|
35
|
-
options: WheelOptions = {},
|
|
38
|
+
options: WheelOptions,
|
|
36
39
|
): WheelInstance {
|
|
37
|
-
let opts =
|
|
40
|
+
let opts = options
|
|
38
41
|
|
|
39
42
|
function hasFocus() {
|
|
40
43
|
const active = element.ownerDocument?.activeElement
|
|
@@ -43,7 +46,7 @@ export function createWheel(
|
|
|
43
46
|
|
|
44
47
|
const handler = (event: Event) => {
|
|
45
48
|
if (opts.requireFocus && !hasFocus()) return
|
|
46
|
-
opts.onWheel
|
|
49
|
+
opts.onWheel(event as WheelEvent)
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
element.addEventListener('wheel', handler, { passive: false })
|
|
@@ -68,6 +68,11 @@ export interface PointsEditorPoint {
|
|
|
68
68
|
element?: Element | null
|
|
69
69
|
/** The wheel option the point resolved, `null` for no wheel. */
|
|
70
70
|
wheel?: ModifierValue<InputEventOption> | null
|
|
71
|
+
/**
|
|
72
|
+
* Called just before the wheel moves this point as the focused one, so that
|
|
73
|
+
* it can report its change as started before the value arrives.
|
|
74
|
+
*/
|
|
75
|
+
beforeWheel?: () => void
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
export interface PointsEditorOptions {
|
|
@@ -326,7 +331,7 @@ export function createPointsEditor(
|
|
|
326
331
|
nudgePoint,
|
|
327
332
|
nudgeFocusedPoint: (axis, direction, modifiers) => {
|
|
328
333
|
for (const [id, read] of points) {
|
|
329
|
-
const { element, wheel, readonly, onChange } = read()
|
|
334
|
+
const { element, wheel, readonly, onChange, beforeWheel } = read()
|
|
330
335
|
// The document the point is in, which need not be the one this script
|
|
331
336
|
// runs in — an editor rendered into an iframe has its own focus.
|
|
332
337
|
const active = element?.ownerDocument.activeElement
|
|
@@ -334,6 +339,7 @@ export function createPointsEditor(
|
|
|
334
339
|
// axes stay part of the same interaction.
|
|
335
340
|
if (!active || !element?.contains(active)) continue
|
|
336
341
|
if (!wheel || readonly || !onChange) return false
|
|
342
|
+
beforeWheel?.()
|
|
337
343
|
nudgePoint(id, axis, direction, wheel, modifiers)
|
|
338
344
|
return true
|
|
339
345
|
}
|