@graview/react 0.1.63 → 0.1.64
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/context.d.ts +11 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +4 -3
- package/dist/context.js.map +1 -1
- package/dist/edge-signs.d.ts +25 -0
- package/dist/edge-signs.d.ts.map +1 -1
- package/dist/edge-signs.js +25 -0
- package/dist/edge-signs.js.map +1 -1
- package/dist/files.d.ts +11 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +11 -0
- package/dist/files.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +1 -1
- package/dist/provider.js.map +1 -1
- package/dist/scene-aim.d.ts +7 -0
- package/dist/scene-aim.d.ts.map +1 -0
- package/dist/scene-aim.js +166 -0
- package/dist/scene-aim.js.map +1 -0
- package/dist/scene-hand.d.ts +28 -2
- package/dist/scene-hand.d.ts.map +1 -1
- package/dist/scene-hand.js +262 -32
- package/dist/scene-hand.js.map +1 -1
- package/dist/scene-root.d.ts.map +1 -1
- package/dist/scene-root.js +70 -8
- package/dist/scene-root.js.map +1 -1
- package/dist/view-host.d.ts +3 -1
- package/dist/view-host.d.ts.map +1 -1
- package/dist/view-host.js +2 -2
- package/dist/view-host.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
/*
|
|
3
|
+
* A PRESS LANDS ON WHAT WAS AIMED AT.
|
|
4
|
+
*
|
|
5
|
+
* A tap that chooses a district can move the city — the sheet it opens on a
|
|
6
|
+
* phone covers the foot, and the chosen district is brought up above it —
|
|
7
|
+
* and a person's next tap, a beat later, was aimed at the picture as it
|
|
8
|
+
* stood when they lifted their finger. The second tap of a double-tap found
|
|
9
|
+
* the zoom's "+" where the district had been, and a quick tap on the next
|
|
10
|
+
* district chose whatever had slid under it.
|
|
11
|
+
*
|
|
12
|
+
* So the tap that chose takes a note of where every card stood as it was
|
|
13
|
+
* pressed (`cards`), and the next press, if it comes within a beat, is
|
|
14
|
+
* judged against that note: when the card it was aimed at is not the one
|
|
15
|
+
* now under it, the press is the aimed card's — a click on it, or, when it
|
|
16
|
+
* is the card the first tap chose, the double-tap that goes in. The press
|
|
17
|
+
* on what slid under the finger is heard by nobody. A press after the beat,
|
|
18
|
+
* or one whose target never moved, is left exactly as it was.
|
|
19
|
+
*/
|
|
20
|
+
/** How long after a tap the next press is judged against the picture the tap was aimed at. */
|
|
21
|
+
export const AIM_MS = 650;
|
|
22
|
+
/** How soon a second tap on the card the first one chose is a double-tap. */
|
|
23
|
+
export const DOUBLE_TAP_MS = 400;
|
|
24
|
+
const CARD = "[data-graview-view]";
|
|
25
|
+
const CHROME = "button, a, input, select, textarea, [role='button'], aside, section[aria-label], [data-graview-popover], [data-graview-offstage], [data-graview-overlay]";
|
|
26
|
+
/** The control a press landed on, inside the scene: chrome over it, or a control a view drew in a card — not a mark a view draws to be picked. */
|
|
27
|
+
function controlUnder(target, ground) {
|
|
28
|
+
if (!(target instanceof Element) || target.closest("[data-graview-pick]"))
|
|
29
|
+
return false;
|
|
30
|
+
const control = target.closest(CHROME);
|
|
31
|
+
return control !== null && control !== ground && ground.contains(control);
|
|
32
|
+
}
|
|
33
|
+
function cardOf(target) {
|
|
34
|
+
return target instanceof Element ? target.closest(CARD) : null;
|
|
35
|
+
}
|
|
36
|
+
/** The card that stood under a point when the note was taken: the smallest box holding it, as the nearest card is drawn over the plot under it. */
|
|
37
|
+
function aimedAt(aim, x, y) {
|
|
38
|
+
let best = null;
|
|
39
|
+
for (const { id, box } of aim.cards) {
|
|
40
|
+
if (x < box.left || x > box.right || y < box.top || y > box.bottom)
|
|
41
|
+
continue;
|
|
42
|
+
const area = box.width * box.height;
|
|
43
|
+
if (!best || area < best.area)
|
|
44
|
+
best = { id, area };
|
|
45
|
+
}
|
|
46
|
+
return best?.id ?? null;
|
|
47
|
+
}
|
|
48
|
+
export function useAimedPress(ground, swallow) {
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const element = ground.current;
|
|
51
|
+
if (!element)
|
|
52
|
+
return;
|
|
53
|
+
let aim = null;
|
|
54
|
+
/** The press now being given to the card it was aimed at, from its pointer-down to its click. */
|
|
55
|
+
let taken = null;
|
|
56
|
+
/** Until when a double-click the browser makes is not heard: the press it ends was given elsewhere. */
|
|
57
|
+
let quietUntil = -Infinity;
|
|
58
|
+
/** While this hook says a press itself: its own click and double-click pass by it. */
|
|
59
|
+
let saying = false;
|
|
60
|
+
const onDown = (event) => {
|
|
61
|
+
const noted = aim;
|
|
62
|
+
aim = null;
|
|
63
|
+
taken = null;
|
|
64
|
+
if (!event.isPrimary || event.button !== 0 || !noted || event.timeStamp - noted.at > AIM_MS)
|
|
65
|
+
return;
|
|
66
|
+
const under = cardOf(event.target)?.getAttribute("data-graview-view") ?? null;
|
|
67
|
+
const aimed = aimedAt(noted, event.clientX, event.clientY);
|
|
68
|
+
/*
|
|
69
|
+
* A FINGER'S DOUBLE-TAP IS OURS TO HEAR. A browser on a phone says a
|
|
70
|
+
* double-click for two taps only sometimes (Safari not at all for a
|
|
71
|
+
* page that is not zoomable, Chrome only when nothing moved between
|
|
72
|
+
* them), so a second tap on the card the first one chose, soon enough,
|
|
73
|
+
* is the double-tap that goes in, whatever is under it now.
|
|
74
|
+
*/
|
|
75
|
+
const doubleTap = event.pointerType === "touch" && noted.on !== null && aimed === noted.on && event.timeStamp - noted.at <= DOUBLE_TAP_MS;
|
|
76
|
+
if (!doubleTap) {
|
|
77
|
+
// What the person aimed at is what is under the finger: nothing moved, nothing to do.
|
|
78
|
+
if (aimed === under)
|
|
79
|
+
return;
|
|
80
|
+
/*
|
|
81
|
+
* A PRESS ON A CONTROL IS THE CONTROL'S — the sheet the tap opened, its
|
|
82
|
+
* "Add", a pane, the zoom. A quick hand reaches for the panel the
|
|
83
|
+
* choice opened the moment it is there, and that press is aimed at
|
|
84
|
+
* the panel, not at the card that stood where it now stands. Only a
|
|
85
|
+
* finger's second tap of a double-tap is taken from a control (above).
|
|
86
|
+
*/
|
|
87
|
+
if (controlUnder(event.target, element))
|
|
88
|
+
return;
|
|
89
|
+
// Aimed at bare ground: whatever is there now keeps its press.
|
|
90
|
+
if (aimed === null)
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
taken = { to: aimed, double: aimed !== null && aimed === noted.on };
|
|
95
|
+
};
|
|
96
|
+
const say = (target, type, from, double) => {
|
|
97
|
+
saying = true;
|
|
98
|
+
try {
|
|
99
|
+
target.dispatchEvent(new MouseEvent(type, { bubbles: true, cancelable: true, clientX: from.clientX, clientY: from.clientY, detail: double ? 2 : 1 }));
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
saying = false;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const onClick = (event) => {
|
|
106
|
+
if (saying)
|
|
107
|
+
return;
|
|
108
|
+
if (taken) {
|
|
109
|
+
const { to, double } = taken;
|
|
110
|
+
taken = null;
|
|
111
|
+
quietUntil = event.timeStamp + 500;
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
const card = to === null ? null : [...element.querySelectorAll(CARD)].find((one) => one.getAttribute("data-graview-view") === to);
|
|
115
|
+
// Aimed at bare ground: the ground's own click, which puts the choice down.
|
|
116
|
+
if (to === null)
|
|
117
|
+
say(element, "click", event, false);
|
|
118
|
+
// The double-tap's second press goes in, as a double-click on the card does; a different card is chosen.
|
|
119
|
+
else if (card)
|
|
120
|
+
say(card, double ? "dblclick" : "click", event, double);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// A tap, not the end of a drag: note where everything stood as it was aimed at, before what it chooses moves anything.
|
|
124
|
+
if (swallow.current)
|
|
125
|
+
return;
|
|
126
|
+
/*
|
|
127
|
+
* A CONTROL moves no card — the zoom over the scene, a pane, a menu, a
|
|
128
|
+
* button a view drew inside its card: pressing "+" or a calendar's
|
|
129
|
+
* "next" twice is pressing it twice. A mark a view draws to be picked
|
|
130
|
+
* (`data-graview-pick`) is a card's own.
|
|
131
|
+
*/
|
|
132
|
+
const control = event.target instanceof Element ? event.target.closest(CHROME) : null;
|
|
133
|
+
if (control && control !== element && element.contains(control) && !event.target.closest("[data-graview-pick]"))
|
|
134
|
+
return;
|
|
135
|
+
const on = cardOf(event.target)?.getAttribute("data-graview-view") ?? null;
|
|
136
|
+
aim = {
|
|
137
|
+
at: event.timeStamp,
|
|
138
|
+
on,
|
|
139
|
+
cards: [...element.querySelectorAll(CARD)].map((card) => ({ id: card.getAttribute("data-graview-view"), box: card.getBoundingClientRect() })),
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
const onDouble = (event) => {
|
|
143
|
+
if (saying || event.timeStamp > quietUntil)
|
|
144
|
+
return;
|
|
145
|
+
// The browser's double-click on what slid under the finger, or a double-tap already said: the aimed card has had its own.
|
|
146
|
+
event.stopPropagation();
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
quietUntil = -Infinity;
|
|
149
|
+
};
|
|
150
|
+
const onUp = (event) => {
|
|
151
|
+
if (taken)
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
};
|
|
154
|
+
element.addEventListener("pointerdown", onDown, true);
|
|
155
|
+
element.addEventListener("pointerup", onUp, true);
|
|
156
|
+
element.addEventListener("click", onClick, true);
|
|
157
|
+
element.addEventListener("dblclick", onDouble, true);
|
|
158
|
+
return () => {
|
|
159
|
+
element.removeEventListener("pointerdown", onDown, true);
|
|
160
|
+
element.removeEventListener("pointerup", onUp, true);
|
|
161
|
+
element.removeEventListener("click", onClick, true);
|
|
162
|
+
element.removeEventListener("dblclick", onDouble, true);
|
|
163
|
+
};
|
|
164
|
+
}, [ground, swallow]);
|
|
165
|
+
}
|
|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IAAI,CAAC,CAAC;YACrD,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACpD,OAAO,CAAC,mBAAmB,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC1D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACxB,CAAC"}
|
package/dist/scene-hand.d.ts
CHANGED
|
@@ -46,12 +46,19 @@ export declare function useHeldDistrict(): {
|
|
|
46
46
|
* and combining that with CSS transforms crashes the renderer. It is not
|
|
47
47
|
* the default path and it is not the measured one.
|
|
48
48
|
*/
|
|
49
|
-
export declare function useWorldShift({ stage, pan, setView, settled, }: {
|
|
49
|
+
export declare function useWorldShift({ stage, pan, zoom, setView, settled, zoomTo, }: {
|
|
50
50
|
readonly stage: RefObject<HTMLElement | null>;
|
|
51
51
|
/** The view's pan: the transform comes off when this has taken the offset. */
|
|
52
52
|
readonly pan: ViewState["pan"];
|
|
53
|
+
/** The city's zoom: the transform comes off when this has taken a hand's zoom, too. */
|
|
54
|
+
readonly zoom: number;
|
|
53
55
|
readonly setView: (update: (current: ViewState) => ViewState) => void;
|
|
54
56
|
readonly settled: () => void;
|
|
57
|
+
/** Letting go of a zoom: the city zoomed by `ratio` about `about` (in the ground's pixels), written into the view once. */
|
|
58
|
+
readonly zoomTo: RefObject<(ratio: number, about: {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
}) => void>;
|
|
55
62
|
}): {
|
|
56
63
|
shiftTo: (wanted: {
|
|
57
64
|
x: number;
|
|
@@ -60,20 +67,33 @@ export declare function useWorldShift({ stage, pan, setView, settled, }: {
|
|
|
60
67
|
x: number;
|
|
61
68
|
y: number;
|
|
62
69
|
}) => void;
|
|
70
|
+
zoomBy: (ratio: number, about: {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
}, dx: number, dy: number, least: number, most: number) => void;
|
|
63
74
|
settle: () => boolean;
|
|
75
|
+
drop: () => void;
|
|
64
76
|
settling: RefObject<boolean>;
|
|
65
77
|
offset: () => {
|
|
66
78
|
x: number;
|
|
67
79
|
y: number;
|
|
80
|
+
s: number;
|
|
68
81
|
};
|
|
69
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* WHETHER A PRESS LANDED IN SOMETHING OF A CARD'S THAT SCROLLS ON ITS OWN —
|
|
85
|
+
* a focused district's list, a long preview. A finger there scrolls it, and
|
|
86
|
+
* the browser takes the touch to do so; the card began to move under the
|
|
87
|
+
* same finger first, and was pinned wherever the scroll left it.
|
|
88
|
+
*/
|
|
89
|
+
export declare function inScroller(target: Element | null, card: Element): boolean;
|
|
70
90
|
/**
|
|
71
91
|
* THE GESTURES THEMSELVES. The threshold is what keeps a click a click:
|
|
72
92
|
* below it nothing has happened and the pointer-up is an ordinary
|
|
73
93
|
* selection; above it the gesture owns the pointer and the click that
|
|
74
94
|
* follows is swallowed.
|
|
75
95
|
*/
|
|
76
|
-
export declare function useSceneDrag({ view, panned, limit, panWithin, moveByTransform, setView, setDragging, noteMoved, shift, district, }: {
|
|
96
|
+
export declare function useSceneDrag({ view, panned, limit, panWithin, moveByTransform, setView, setDragging, noteMoved, shift, district, pinching, }: {
|
|
77
97
|
readonly view: ViewState;
|
|
78
98
|
/** The pan baked into the drawn cards: a card's pin is stored without it. */
|
|
79
99
|
readonly panned: {
|
|
@@ -102,11 +122,14 @@ export declare function useSceneDrag({ view, panned, limit, panWithin, moveByTra
|
|
|
102
122
|
readonly noteMoved: () => void;
|
|
103
123
|
readonly shift: ReturnType<typeof useWorldShift>;
|
|
104
124
|
readonly district: ReturnType<typeof useHeldDistrict>;
|
|
125
|
+
/** Two fingers are on the scene (`useWheelAndPinch`): they zoom, and no one finger's drag is begun or carried on. */
|
|
126
|
+
readonly pinching: RefObject<boolean>;
|
|
105
127
|
}): {
|
|
106
128
|
onGroundDown: (event: ReactPointerEvent<HTMLDivElement>) => void;
|
|
107
129
|
onCardDown: (node: SceneNode, event: ReactPointerEvent<HTMLElement>) => void;
|
|
108
130
|
onDragMove: (event: ReactPointerEvent<HTMLElement>) => void;
|
|
109
131
|
onDragUp: () => void;
|
|
132
|
+
onDragCancel: () => void;
|
|
110
133
|
swallow: RefObject<boolean>;
|
|
111
134
|
};
|
|
112
135
|
/**
|
|
@@ -121,5 +144,8 @@ export declare function useWheelAndPinch({ stage, view, setView, }: {
|
|
|
121
144
|
}): {
|
|
122
145
|
zoomAbout: RefObject<(factor: number, clientX?: number, clientY?: number) => void>;
|
|
123
146
|
panBy: RefObject<(dx: number, dy: number) => void>;
|
|
147
|
+
pinchBy: RefObject<(factor: number, clientX: number, clientY: number, dx: number, dy: number) => void>;
|
|
148
|
+
pinchDone: RefObject<() => void>;
|
|
149
|
+
pinching: RefObject<boolean>;
|
|
124
150
|
};
|
|
125
151
|
//# sourceMappingURL=scene-hand.d.ts.map
|
package/dist/scene-hand.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene-hand.d.ts","sourceRoot":"","sources":["../src/scene-hand.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EAA6D,KAAK,YAAY,IAAI,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1I,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAkBjD,sFAAsF;AACtF,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH;;;;;;;GAOG;AACH,wBAAgB,OAAO,IAAI;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAAC,QAA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