drawnui-react 0.1.0-preview.37 → 0.1.0-preview.39
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 +94 -13
- package/SKIPPED.md +6 -6
- package/dist/controls/AnimatedFramesRenderer.d.ts +2 -0
- package/dist/controls/AnimatedFramesRenderer.js +2 -0
- package/dist/controls/DrawnGame.d.ts +5 -1
- package/dist/controls/DrawnGame.js +22 -4
- package/dist/controls/SkiaButton.d.ts +2 -2
- package/dist/controls/SkiaButton.js +3 -2
- package/dist/controls/SkiaCarousel.d.ts +1 -1
- package/dist/controls/SkiaCarousel.js +5 -1
- package/dist/controls/SkiaDrawer.d.ts +13 -0
- package/dist/controls/SkiaDrawer.js +40 -7
- package/dist/controls/SkiaEditor.d.ts +3 -1
- package/dist/controls/SkiaEditor.js +5 -0
- package/dist/controls/SkiaGif.d.ts +4 -0
- package/dist/controls/SkiaGif.js +13 -2
- package/dist/controls/SkiaImage.d.ts +5 -0
- package/dist/controls/SkiaImage.js +33 -4
- package/dist/controls/SkiaLabel.d.ts +7 -1
- package/dist/controls/SkiaLabel.js +11 -4
- package/dist/controls/SkiaLayout.js +3 -1
- package/dist/controls/SkiaLottie.js +1 -1
- package/dist/controls/SkiaRadioButton.d.ts +2 -0
- package/dist/controls/SkiaRadioButton.js +10 -0
- package/dist/controls/SkiaScroll.js +18 -9
- package/dist/controls/SkiaShaderCarousel.d.ts +6 -1
- package/dist/controls/SkiaShaderCarousel.js +17 -5
- package/dist/controls/SkiaSprite.d.ts +3 -0
- package/dist/controls/SkiaSprite.js +18 -10
- package/dist/controls/SkiaSvg.d.ts +4 -0
- package/dist/controls/SkiaSvg.js +27 -3
- package/dist/controls/SnappingLayout.js +2 -1
- package/dist/core/Accessibility.d.ts +26 -2
- package/dist/core/Accessibility.js +99 -5
- package/dist/core/Canvas.d.ts +34 -3
- package/dist/core/Canvas.js +104 -14
- package/dist/core/Gestures.d.ts +47 -0
- package/dist/core/Gestures.js +93 -0
- package/dist/core/ImageEffects.d.ts +2 -0
- package/dist/core/ImageEffects.js +2 -0
- package/dist/core/KeyboardManager.d.ts +20 -0
- package/dist/core/KeyboardManager.js +54 -13
- package/dist/core/PopupWindows.d.ts +2 -0
- package/dist/core/PopupWindows.js +2 -0
- package/dist/core/SkiaControl.d.ts +26 -1
- package/dist/core/SkiaControl.js +40 -3
- package/dist/react/SkiaShell.js +32 -12
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +15 -5
- package/dist/react/reconciler.d.ts +18 -0
- package/dist/react/reconciler.js +31 -1
- package/package.json +16 -2
|
@@ -170,7 +170,7 @@ export class SkiaAccessibilityManager {
|
|
|
170
170
|
/**
|
|
171
171
|
* Moves keyboard focus between the items of the group around `focused`, by item index like a native list: Down / Up in
|
|
172
172
|
* a Column, Right / Left in a Row, all four in a Wrap, a Grid or a Split layout (Up / Down by one row), Home / End to the
|
|
173
|
-
* first / last item, PageDown / PageUp by one viewport of the scroll around it.
|
|
173
|
+
* first / last item, PageDown / PageUp by one viewport of the scroll around it. The ends stop the arrows, unless the group has KeyboardWrap. The target is the
|
|
174
174
|
* item itself when it is an interactive node, else its first interactive node; items the pointer cannot use are
|
|
175
175
|
* skipped. An item not realized (recycled cells) is scrolled in with ScrollToIndex when the group is the scroll's
|
|
176
176
|
* content, and focused once drawn. True when the key belongs to the group.
|
|
@@ -180,6 +180,28 @@ export class SkiaAccessibilityManager {
|
|
|
180
180
|
if (!found)
|
|
181
181
|
return false;
|
|
182
182
|
const { Holder: group, Item: item } = found;
|
|
183
|
+
// a menu, list or radio group whose items are not the children of one layout (a panel with a title, a divider and
|
|
184
|
+
// columns of items): its items in reading order, one after another (drawnui-cross 6ao rule 1b, as DrawnUi.Rust)
|
|
185
|
+
const role = found.Group.AccessibilityRole;
|
|
186
|
+
const linear = role === Aria.RoleMenu || role === Aria.RoleMenuBar || role === Aria.RoleList || role === Aria.RoleListBox || role === Aria.RoleRadioGroup;
|
|
187
|
+
const holdsMany = (child) => this.Snapshot.filter((n) => n.CanInteract && IsInside(n.Source, child)).length > 1;
|
|
188
|
+
if (linear && item !== focused && ViewsOf(group).some(holdsMany)) {
|
|
189
|
+
const items = this.Snapshot.filter((n) => n.CanInteract && SkiaAccessibilityManager.TryFindGroup(n.Source)?.Group === found.Group).map((n) => n.Source);
|
|
190
|
+
const current = items.indexOf(focused);
|
|
191
|
+
if (current < 0)
|
|
192
|
+
return false;
|
|
193
|
+
const n = items.length, wrap = found.Group.KeyboardWrap || group.KeyboardWrap;
|
|
194
|
+
const target = key === "ArrowDown" || key === "ArrowRight" ? (wrap ? (current + 1) % n : Math.min(current + 1, n - 1))
|
|
195
|
+
: key === "ArrowUp" || key === "ArrowLeft" ? (wrap ? (current - 1 + n) % n : Math.max(current - 1, 0))
|
|
196
|
+
: key === "Home" ? 0 : key === "End" ? n - 1 : -1;
|
|
197
|
+
if (target < 0)
|
|
198
|
+
return false;
|
|
199
|
+
if (target !== current) {
|
|
200
|
+
this.RequestKeyboardFocus(items[target]);
|
|
201
|
+
found.Group.Superview?.Update();
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
183
205
|
const scroll = FindScroll(group), axis = AxisOf(group), count = ItemCount(group);
|
|
184
206
|
const current = this.groupRequest?.Group === group ? this.groupRequest.Index : IndexOf(group, item);
|
|
185
207
|
if (current < 0 || count < 1)
|
|
@@ -227,6 +249,9 @@ export class SkiaAccessibilityManager {
|
|
|
227
249
|
}
|
|
228
250
|
else
|
|
229
251
|
return false;
|
|
252
|
+
// KeyboardWrap on the group: the arrows go round, the last item to the first and back
|
|
253
|
+
if ((target < 0 || target >= count) && key.startsWith("Arrow") && (found.Group.KeyboardWrap || group.KeyboardWrap))
|
|
254
|
+
target = target < 0 ? count - 1 : 0;
|
|
230
255
|
if (target < 0 || target >= count || target === current)
|
|
231
256
|
return true; // at the end of the group nothing happens, the key still belongs to it
|
|
232
257
|
this.groupRequest = { Group: group, Scroll: scroll, Index: target, Step: step, Deadline: performance.now() + 3000, ScrollIssued: false };
|
|
@@ -238,7 +263,46 @@ export class SkiaAccessibilityManager {
|
|
|
238
263
|
popupFocusRoot;
|
|
239
264
|
focusAnyInside = false;
|
|
240
265
|
/** The keyboard goes to this control at the end of the next frame (a popup closed: back to what opened it). */
|
|
241
|
-
RequestKeyboardFocus(control) { this.
|
|
266
|
+
RequestKeyboardFocus(control) { if (!this.appFocusThisFrame)
|
|
267
|
+
this.focusRequest = control; }
|
|
268
|
+
appFocus;
|
|
269
|
+
appFocusDeadline = 0;
|
|
270
|
+
appFocusThisFrame = false; // until the frame end: the app said where the focus goes, the library's moves give way
|
|
271
|
+
clearFocusRequest = false;
|
|
272
|
+
/**
|
|
273
|
+
* App code moves the keyboard and screen-reader focus at the end of the next frame (C# DrawnView.SetAccessibilityFocus,
|
|
274
|
+
* Rust `Cx::set_accessibility_focus`), for a custom menu that moves its highlight: to `control`, which gets it once
|
|
275
|
+
* drawn, within 3 seconds. It wins over the library's own moves in the same frame (a group's arrow move, a closed popup
|
|
276
|
+
* window giving the keyboard back to its opener); undefined cancels a move still waiting, the focus stays where it is.
|
|
277
|
+
* The focus ring shows only if the keyboard is in use (the browser's focus-visible).
|
|
278
|
+
*/
|
|
279
|
+
SetAccessibilityFocus(control) {
|
|
280
|
+
this.appFocusThisFrame = true;
|
|
281
|
+
this.focusRequest = undefined;
|
|
282
|
+
this.groupRequest = undefined;
|
|
283
|
+
this.appFocus = control;
|
|
284
|
+
this.appFocusDeadline = performance.now() + 3000;
|
|
285
|
+
control?.Superview?.Update();
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* No drawn control keeps the keyboard and screen-reader focus (C# KeyboardFocusNode = null): at the end of the next
|
|
289
|
+
* frame the DOM focus goes back to the canvas and the keys belong to the app again.
|
|
290
|
+
*/
|
|
291
|
+
ClearKeyboardFocus() { this.appFocus = undefined; this.clearFocusRequest = true; }
|
|
292
|
+
ProcessAppFocus(scale, w, h, requestFrame) {
|
|
293
|
+
const wanted = this.appFocus;
|
|
294
|
+
if (wanted.IsDisposed || performance.now() > this.appFocusDeadline) {
|
|
295
|
+
this.appFocus = undefined;
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
this.Rebuild(scale, w, h);
|
|
299
|
+
if (!this.Snapshot.some((n) => n.Source === wanted)) {
|
|
300
|
+
requestFrame();
|
|
301
|
+
return;
|
|
302
|
+
} // not drawn yet: look again next frame
|
|
303
|
+
this.appFocus = undefined;
|
|
304
|
+
this.Focus(wanted);
|
|
305
|
+
}
|
|
242
306
|
popupScope;
|
|
243
307
|
/**
|
|
244
308
|
* While set, Tab stays inside this control: only its nodes are Tab stops and Tab / Shift+Tab go round them: the top
|
|
@@ -284,7 +348,7 @@ export class SkiaAccessibilityManager {
|
|
|
284
348
|
// back unless the keyboard went elsewhere meanwhile; a keyboard node that left with the modal (disposed, detached) was in it
|
|
285
349
|
const leftWithIt = !!keyboard && (keyboard.IsDisposed || !keyboard.Superview);
|
|
286
350
|
if (back && (!keyboard || leftWithIt || IsInside(keyboard, previous)) && (!next || IsInside(back, next)))
|
|
287
|
-
this.
|
|
351
|
+
this.RequestKeyboardFocus(back);
|
|
288
352
|
}
|
|
289
353
|
/** The Tab stop after (or before) `from` in reading order; inside a KeyboardScope it goes round, never leaving. */
|
|
290
354
|
NextTabStop(from, forward) {
|
|
@@ -361,6 +425,9 @@ export class SkiaAccessibilityManager {
|
|
|
361
425
|
}
|
|
362
426
|
FocusFromKeyboard(node, scale, w, h) {
|
|
363
427
|
this.Rebuild(scale, w, h); // the overlay looks the node up in the snapshot: make sure it is there now
|
|
428
|
+
this.Focus(node);
|
|
429
|
+
}
|
|
430
|
+
Focus(node) {
|
|
364
431
|
this.NoteFocus(node);
|
|
365
432
|
this.FocusedNode = node;
|
|
366
433
|
for (const cb of this.keyboardFocusRequested)
|
|
@@ -375,6 +442,14 @@ export class SkiaAccessibilityManager {
|
|
|
375
442
|
for (const cb of this.liveUpdated)
|
|
376
443
|
cb(node);
|
|
377
444
|
}
|
|
445
|
+
/** What the last snapshot says for each live region, to rebuild on the next frame when that changes. */
|
|
446
|
+
liveSaid = new Map();
|
|
447
|
+
LiveChanged() {
|
|
448
|
+
for (const [control, said] of this.liveSaid)
|
|
449
|
+
if (!control.IsDisposed && (control.AccessibilityLabel ?? "") !== said)
|
|
450
|
+
return true;
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
378
453
|
ForceRebuildOnNextFrame() { this.lastRebuild = -Infinity; this.dirty = true; }
|
|
379
454
|
Unregister(node) {
|
|
380
455
|
if (this.nodes.delete(node)) {
|
|
@@ -399,12 +474,26 @@ export class SkiaAccessibilityManager {
|
|
|
399
474
|
if (AccessibilityModals.size > 0 || this.ActiveModal)
|
|
400
475
|
this.UpdateActiveModal();
|
|
401
476
|
this.ProcessGroupFocus(scale, canvasWidthPx, canvasHeightPx, requestFrame);
|
|
477
|
+
if (this.clearFocusRequest) {
|
|
478
|
+
this.clearFocusRequest = false;
|
|
479
|
+
this.FocusedNode = undefined;
|
|
480
|
+
for (const cb of this.keyboardFocusRequested)
|
|
481
|
+
cb(undefined);
|
|
482
|
+
}
|
|
483
|
+
if (this.appFocus)
|
|
484
|
+
this.ProcessAppFocus(scale, canvasWidthPx, canvasHeightPx, requestFrame);
|
|
402
485
|
if (this.focusRequest || this.popupFocusRoot)
|
|
403
486
|
this.ProcessFocusRequests(scale, canvasWidthPx, canvasHeightPx);
|
|
487
|
+
this.appFocusThisFrame = false;
|
|
404
488
|
if (this.nodes.size === 0 && this.Snapshot.length === 0)
|
|
405
489
|
return;
|
|
406
490
|
const now = performance.now();
|
|
407
491
|
const wait = this.MinUpdateIntervalMs - (now - this.lastRebuild);
|
|
492
|
+
// a live region whose text changed is read on the next frame, not at the next timed rebuild (accessibility-plan B2)
|
|
493
|
+
if (wait > 0 && this.liveSaid.size > 0 && this.LiveChanged()) {
|
|
494
|
+
this.Rebuild(scale, canvasWidthPx, canvasHeightPx);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
408
497
|
if (wait > 0) {
|
|
409
498
|
// rate-limited: rendering is on demand, so make sure a frame comes back once the interval has passed
|
|
410
499
|
if (!this.pending)
|
|
@@ -440,7 +529,7 @@ export class SkiaAccessibilityManager {
|
|
|
440
529
|
list.push({
|
|
441
530
|
Id: n.AccessibilityId, Label: n.AccessibilityLabel, Hint: n.AccessibilityHint, Role: n.AccessibilityRole, Value: n.AccessibilityValue,
|
|
442
531
|
Rect: new SKRect(px.Left / scale, px.Top / scale, px.Right / scale, px.Bottom / scale),
|
|
443
|
-
CanInteract: n.AccessibilityCanInteract, IsPressed: n.AccessibilityIsPressed, Live: n.AccessibilityLive, Source: n,
|
|
532
|
+
CanInteract: n.AccessibilityCanInteract, IsPressed: n.AccessibilityIsPressed, Expanded: n.AccessibilityExpanded, Live: n.AccessibilityLive, Source: n,
|
|
444
533
|
Disabled: !n.AccessibilityCanInteract && Aria.IsInteractiveRole(n.AccessibilityRole),
|
|
445
534
|
TextLines: n.AccessibilityTextSelectable ? n.GetAccessibilityTextLines(scale) : undefined,
|
|
446
535
|
});
|
|
@@ -462,6 +551,11 @@ export class SkiaAccessibilityManager {
|
|
|
462
551
|
}
|
|
463
552
|
start = i;
|
|
464
553
|
}
|
|
554
|
+
this.liveSaid.clear();
|
|
555
|
+
// the control's own name (a name given to a child that says it is no change)
|
|
556
|
+
for (const n of list)
|
|
557
|
+
if (n.Live)
|
|
558
|
+
this.liveSaid.set(n.Source, n.Source.AccessibilityLabel ?? "");
|
|
465
559
|
if (SkiaAccessibilityManager.Same(list, this.Snapshot))
|
|
466
560
|
return;
|
|
467
561
|
this.Snapshot = list;
|
|
@@ -474,7 +568,7 @@ export class SkiaAccessibilityManager {
|
|
|
474
568
|
for (let i = 0; i < a.length; i++) {
|
|
475
569
|
const x = a[i], y = b[i];
|
|
476
570
|
if (x.Source !== y.Source || x.Label !== y.Label || x.Hint !== y.Hint || x.Role !== y.Role || x.CanInteract !== y.CanInteract || x.Disabled !== y.Disabled
|
|
477
|
-
|| x.IsPressed !== y.IsPressed || x.Live !== y.Live || !SameValue(x.Value, y.Value)
|
|
571
|
+
|| x.IsPressed !== y.IsPressed || x.Expanded !== y.Expanded || x.Live !== y.Live || !SameValue(x.Value, y.Value)
|
|
478
572
|
|| Math.abs(x.Rect.Left - y.Rect.Left) > 0.5 || Math.abs(x.Rect.Top - y.Rect.Top) > 0.5
|
|
479
573
|
|| Math.abs(x.Rect.Right - y.Rect.Right) > 0.5 || Math.abs(x.Rect.Bottom - y.Rect.Bottom) > 0.5)
|
|
480
574
|
return false;
|
package/dist/core/Canvas.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Surface } from "canvaskit-wasm";
|
|
2
|
-
import type
|
|
2
|
+
import { type DrawingContext, type SkiaControl } from "./SkiaControl";
|
|
3
3
|
import type { AnimatorBase } from "./Animators";
|
|
4
4
|
import { SkiaAccessibilityManager } from "./Accessibility";
|
|
5
5
|
import { HoverManager } from "./Hover";
|
|
@@ -61,6 +61,15 @@ export declare class Canvas {
|
|
|
61
61
|
private popupKeysHooked;
|
|
62
62
|
/** Raised when a popup window closed: picked, a press outside, Escape, the wheel, window blur or ClosePopupWindow. */
|
|
63
63
|
readonly PopupWindowClosed: Set<(id: PopupId) => void>;
|
|
64
|
+
/** The root controls of the open popup windows, bottom to top: a read-only view for tools (a new array per read). */
|
|
65
|
+
get PopupWindowRoots(): readonly SkiaControl[];
|
|
66
|
+
private wasDrawnListeners?;
|
|
67
|
+
/**
|
|
68
|
+
* Handlers run at the end of every drawn frame, after the `WasDrawn` callback and before the surface is flushed (a
|
|
69
|
+
* tool drawing an overlay on `Surface.getCanvas()`). Made on first use: a canvas without listeners does no work.
|
|
70
|
+
*/
|
|
71
|
+
get WasDrawnListeners(): Set<(sender: Canvas) => void>;
|
|
72
|
+
private readonly raiseWasDrawn;
|
|
64
73
|
/**
|
|
65
74
|
* Shows `content` over everything, opening from `anchor` the way native menus do: at a point (a right click, canvas
|
|
66
75
|
* points), or below a rect or a control (a dropdown), flipped to the other side where it does not fit. It closes with
|
|
@@ -76,6 +85,19 @@ export declare class Canvas {
|
|
|
76
85
|
ClosePopupWindows(): void;
|
|
77
86
|
/** The popup window is still open. */
|
|
78
87
|
IsPopupWindowOpen(id: PopupId): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Moves the keyboard and screen-reader focus to `control` at the end of the next frame, for app code such as a custom
|
|
90
|
+
* menu that moves its highlight (C# DrawnView.SetAccessibilityFocus). A control not drawn yet gets it once it is, within
|
|
91
|
+
* 3 seconds. It wins over the library's own moves in the same frame (a closed popup window giving the keyboard back to
|
|
92
|
+
* its opener); undefined cancels a move still waiting. The focus ring shows only if the keyboard is in use.
|
|
93
|
+
*/
|
|
94
|
+
SetAccessibilityFocus(control?: SkiaControl): void;
|
|
95
|
+
/**
|
|
96
|
+
* The drawn control with the keyboard and screen-reader focus (C# KeyboardFocusNode). Set undefined to let no drawn
|
|
97
|
+
* control keep it: the DOM focus goes back to the canvas and the keys belong to the app; a control moves it there.
|
|
98
|
+
*/
|
|
99
|
+
get KeyboardFocusNode(): SkiaControl | undefined;
|
|
100
|
+
set KeyboardFocusNode(control: SkiaControl | undefined);
|
|
79
101
|
/** True while a popup window that takes input is open. */
|
|
80
102
|
get HasPopupWindows(): boolean;
|
|
81
103
|
/** The content of the top popup window that takes input. */
|
|
@@ -85,7 +107,6 @@ export declare class Canvas {
|
|
|
85
107
|
RaisePopupWindowClosed(id: PopupId): void;
|
|
86
108
|
private AfterPopupsChanged;
|
|
87
109
|
private readonly onPopupKey;
|
|
88
|
-
private readonly onPopupChar;
|
|
89
110
|
private HookPopupKeys;
|
|
90
111
|
private readonly onWindowBlur;
|
|
91
112
|
private content?;
|
|
@@ -142,6 +163,13 @@ export declare class Canvas {
|
|
|
142
163
|
readonly AnimatingControls: Map<number, AnimatorBase>;
|
|
143
164
|
RegisterAnimator(animator: AnimatorBase): boolean;
|
|
144
165
|
UnregisterAnimator(uid: number): void;
|
|
166
|
+
/**
|
|
167
|
+
* `root` leaves this canvas (removed from its parent, replaced as content, disposed): what runs for its subtree stops,
|
|
168
|
+
* as DrawnUi.Rust 44c718f. Its animators leave the frame loop: disposed, they stop; only removed, they pause and wait on
|
|
169
|
+
* their control (PendingUnattachedAnimators), going on from there when it is arranged on a canvas again. A focused editor in it loses the
|
|
170
|
+
* focus, a game in it stops getting keys (CanvasLeaveWatchers). Runs once per removal, never per frame.
|
|
171
|
+
*/
|
|
172
|
+
ControlLeft(root: SkiaControl, disposed: boolean): void;
|
|
145
173
|
/** Ticks every registered animator once; returns how many ran. */
|
|
146
174
|
protected ExecuteAnimators(frameTimeNanos: number): number;
|
|
147
175
|
private wakeTimer;
|
|
@@ -237,6 +265,10 @@ export declare class Canvas {
|
|
|
237
265
|
private DetachInput;
|
|
238
266
|
/** Port of DrawnUi.Blazor Canvas.OnTouchAction: per-pointer state machine producing Down / Panning / Tapped / Up. */
|
|
239
267
|
OnTouchAction(args: TouchActionEventArgs): void;
|
|
268
|
+
/** The fingers down, for TouchActionEventArgs.Manipulation (pinch and turn). */
|
|
269
|
+
private readonly fingers;
|
|
270
|
+
/** The press had a second finger: it is no tap (AppoMobi.Blazor.Gestures). */
|
|
271
|
+
private multiTouch;
|
|
240
272
|
private readonly longPressTimers;
|
|
241
273
|
private readonly longPressed;
|
|
242
274
|
/** The long press of a new press: due LongPressTimeMs later unless the pointer moves away or lets go. */
|
|
@@ -262,7 +294,6 @@ export declare class Canvas {
|
|
|
262
294
|
*/
|
|
263
295
|
get ArrowsStartKeyboardNavigation(): boolean;
|
|
264
296
|
set ArrowsStartKeyboardNavigation(v: boolean);
|
|
265
|
-
private readonly onArrowChar;
|
|
266
297
|
private readonly onArrowKey;
|
|
267
298
|
private focusedChild?;
|
|
268
299
|
private focusAtDown?;
|
package/dist/core/Canvas.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CanvasLeaveWatchers } from "./SkiaControl";
|
|
1
2
|
import { Super } from "./Super";
|
|
2
3
|
import { SkiaAccessibilityManager } from "./Accessibility";
|
|
3
4
|
import { HoverManager } from "./Hover";
|
|
@@ -5,7 +6,7 @@ import { TooltipController } from "./Tooltips";
|
|
|
5
6
|
import { PopupAnchor, PopupLayer } from "./PopupWindows";
|
|
6
7
|
import { KeyboardManager } from "./KeyboardManager";
|
|
7
8
|
import { Colors, SKRect } from "./Types";
|
|
8
|
-
import { ContextMenuEventArgs, GestureEventProcessingInfo, PointerData, SKPoint, SkiaGesturesParameters, TouchActionEventArgs, } from "./Gestures";
|
|
9
|
+
import { ContextMenuEventArgs, GestureEventProcessingInfo, MultitouchTracker, PointerData, SKPoint, SkiaGesturesParameters, TouchActionEventArgs, } from "./Gestures";
|
|
9
10
|
/**
|
|
10
11
|
* Mirrors DrawnUi Canvas (DrawnView): hosts one Content control on an HTML canvas element,
|
|
11
12
|
* owns RenderingScale (devicePixelRatio), the surface, the on-demand frame loop and raw input.
|
|
@@ -62,6 +63,15 @@ export class Canvas {
|
|
|
62
63
|
popupKeysHooked = false;
|
|
63
64
|
/** Raised when a popup window closed: picked, a press outside, Escape, the wheel, window blur or ClosePopupWindow. */
|
|
64
65
|
PopupWindowClosed = new Set();
|
|
66
|
+
/** The root controls of the open popup windows, bottom to top: a read-only view for tools (a new array per read). */
|
|
67
|
+
get PopupWindowRoots() { return this.popupLayer?.Roots ?? []; }
|
|
68
|
+
wasDrawnListeners;
|
|
69
|
+
/**
|
|
70
|
+
* Handlers run at the end of every drawn frame, after the `WasDrawn` callback and before the surface is flushed (a
|
|
71
|
+
* tool drawing an overlay on `Surface.getCanvas()`). Made on first use: a canvas without listeners does no work.
|
|
72
|
+
*/
|
|
73
|
+
get WasDrawnListeners() { return this.wasDrawnListeners ??= new Set(); }
|
|
74
|
+
raiseWasDrawn = (f) => f(this);
|
|
65
75
|
/**
|
|
66
76
|
* Shows `content` over everything, opening from `anchor` the way native menus do: at a point (a right click, canvas
|
|
67
77
|
* points), or below a rect or a control (a dropdown), flipped to the other side where it does not fit. It closes with
|
|
@@ -82,6 +92,25 @@ export class Canvas {
|
|
|
82
92
|
ClosePopupWindows() { this.popups.CloseAll(true); this.AfterPopupsChanged(); }
|
|
83
93
|
/** The popup window is still open. */
|
|
84
94
|
IsPopupWindowOpen(id) { return this.popups.IsOpen(id); }
|
|
95
|
+
/**
|
|
96
|
+
* Moves the keyboard and screen-reader focus to `control` at the end of the next frame, for app code such as a custom
|
|
97
|
+
* menu that moves its highlight (C# DrawnView.SetAccessibilityFocus). A control not drawn yet gets it once it is, within
|
|
98
|
+
* 3 seconds. It wins over the library's own moves in the same frame (a closed popup window giving the keyboard back to
|
|
99
|
+
* its opener); undefined cancels a move still waiting. The focus ring shows only if the keyboard is in use.
|
|
100
|
+
*/
|
|
101
|
+
SetAccessibilityFocus(control) { this.AccessibilityManager.SetAccessibilityFocus(control); this.Update(); }
|
|
102
|
+
/**
|
|
103
|
+
* The drawn control with the keyboard and screen-reader focus (C# KeyboardFocusNode). Set undefined to let no drawn
|
|
104
|
+
* control keep it: the DOM focus goes back to the canvas and the keys belong to the app; a control moves it there.
|
|
105
|
+
*/
|
|
106
|
+
get KeyboardFocusNode() { return this.AccessibilityManager.FocusedNode; }
|
|
107
|
+
set KeyboardFocusNode(control) {
|
|
108
|
+
if (control)
|
|
109
|
+
this.AccessibilityManager.SetAccessibilityFocus(control);
|
|
110
|
+
else
|
|
111
|
+
this.AccessibilityManager.ClearKeyboardFocus();
|
|
112
|
+
this.Update();
|
|
113
|
+
}
|
|
85
114
|
/** True while a popup window that takes input is open. */
|
|
86
115
|
get HasPopupWindows() { return this.popups.HasInteractive; }
|
|
87
116
|
/** The content of the top popup window that takes input. */
|
|
@@ -96,24 +125,29 @@ export class Canvas {
|
|
|
96
125
|
this.Hover.RequestCheck();
|
|
97
126
|
this.Update();
|
|
98
127
|
}
|
|
99
|
-
onPopupKey = (key) => {
|
|
100
|
-
this.
|
|
101
|
-
|
|
128
|
+
onPopupKey = (key) => {
|
|
129
|
+
if (key !== "Escape" || !this.popups.CloseTop())
|
|
130
|
+
return false;
|
|
131
|
+
this.AfterPopupsChanged();
|
|
132
|
+
return true;
|
|
133
|
+
};
|
|
102
134
|
HookPopupKeys(on) {
|
|
103
135
|
if (on === this.popupKeysHooked)
|
|
104
136
|
return;
|
|
105
137
|
this.popupKeysHooked = on;
|
|
106
138
|
if (on)
|
|
107
|
-
KeyboardManager.
|
|
139
|
+
KeyboardManager.SubscribeNavigation(this.onPopupKey);
|
|
108
140
|
else
|
|
109
|
-
KeyboardManager.
|
|
141
|
+
KeyboardManager.UnsubscribeNavigation(this.onPopupKey);
|
|
110
142
|
}
|
|
111
143
|
onWindowBlur = () => this.OnWindowDeactivated();
|
|
112
144
|
content;
|
|
113
145
|
get Content() { return this.content; }
|
|
114
146
|
set Content(value) {
|
|
115
|
-
if (this.content)
|
|
147
|
+
if (this.content && this.content !== value) {
|
|
148
|
+
this.ControlLeft(this.content, false);
|
|
116
149
|
this.content._superview = undefined;
|
|
150
|
+
}
|
|
117
151
|
this.content = value;
|
|
118
152
|
if (value) {
|
|
119
153
|
value.Parent = undefined;
|
|
@@ -298,6 +332,9 @@ export class Canvas {
|
|
|
298
332
|
this.Update(); // animators running: keep frames coming
|
|
299
333
|
// C# order: WasDrawn at the end of the frame, then the frame counts as rendered
|
|
300
334
|
this.WasDrawn?.(this);
|
|
335
|
+
const listeners = this.wasDrawnListeners;
|
|
336
|
+
if (listeners !== undefined && listeners.size > 0)
|
|
337
|
+
listeners.forEach(this.raiseWasDrawn);
|
|
301
338
|
if (!this.WasRendered && canRender)
|
|
302
339
|
this.WasRendered = true;
|
|
303
340
|
}
|
|
@@ -321,6 +358,37 @@ export class Canvas {
|
|
|
321
358
|
return true;
|
|
322
359
|
}
|
|
323
360
|
UnregisterAnimator(uid) { this.AnimatingControls.delete(uid); }
|
|
361
|
+
/**
|
|
362
|
+
* `root` leaves this canvas (removed from its parent, replaced as content, disposed): what runs for its subtree stops,
|
|
363
|
+
* as DrawnUi.Rust 44c718f. Its animators leave the frame loop: disposed, they stop; only removed, they pause and wait on
|
|
364
|
+
* their control (PendingUnattachedAnimators), going on from there when it is arranged on a canvas again. A focused editor in it loses the
|
|
365
|
+
* focus, a game in it stops getting keys (CanvasLeaveWatchers). Runs once per removal, never per frame.
|
|
366
|
+
*/
|
|
367
|
+
ControlLeft(root, disposed) {
|
|
368
|
+
const inside = (c) => { for (let p = c; p; p = p.Parent)
|
|
369
|
+
if (p === root)
|
|
370
|
+
return true; return false; };
|
|
371
|
+
for (const a of this.AnimatingControls.values()) {
|
|
372
|
+
const control = a.Parent;
|
|
373
|
+
if (!control || !inside(control))
|
|
374
|
+
continue;
|
|
375
|
+
this.AnimatingControls.delete(a.Uid);
|
|
376
|
+
if (disposed || control.IsDisposed)
|
|
377
|
+
a.Stop();
|
|
378
|
+
else {
|
|
379
|
+
// paused as a hidden control's animator is: the time off the canvas is not counted when it goes on
|
|
380
|
+
if (!a.IsPaused) {
|
|
381
|
+
a.Pause();
|
|
382
|
+
a.PausedWhileHidden = true;
|
|
383
|
+
}
|
|
384
|
+
if (!control.PendingUnattachedAnimators?.includes(a))
|
|
385
|
+
(control.PendingUnattachedAnimators ??= []).push(a);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
for (const c of [...CanvasLeaveWatchers])
|
|
389
|
+
if (inside(c))
|
|
390
|
+
c.OnLeftCanvas();
|
|
391
|
+
}
|
|
324
392
|
/** Ticks every registered animator once; returns how many ran. */
|
|
325
393
|
ExecuteAnimators(frameTimeNanos) {
|
|
326
394
|
let executed = 0, wake = Infinity;
|
|
@@ -726,6 +794,7 @@ export class Canvas {
|
|
|
726
794
|
this.activeTouchIds.clear();
|
|
727
795
|
this.pointerDownArgs.clear();
|
|
728
796
|
this.previousTouchArgs.clear();
|
|
797
|
+
this.fingers.Reset();
|
|
729
798
|
}
|
|
730
799
|
/** Port of DrawnUi.Blazor Canvas.OnTouchAction: per-pointer state machine producing Down / Panning / Tapped / Up. */
|
|
731
800
|
OnTouchAction(args) {
|
|
@@ -734,6 +803,17 @@ export class Canvas {
|
|
|
734
803
|
const id = args.Id;
|
|
735
804
|
if (args.Type === "Pressed") {
|
|
736
805
|
this.ArmLongPress(id, args);
|
|
806
|
+
// the fingers for pinch and turn: the first restarts them, a second one makes the press no tap
|
|
807
|
+
if (this.activeTouchIds.size === 0) {
|
|
808
|
+
this.fingers.Restart(id, args.Location);
|
|
809
|
+
this.multiTouch = false;
|
|
810
|
+
}
|
|
811
|
+
else {
|
|
812
|
+
for (const [other, last] of this.previousTouchArgs)
|
|
813
|
+
this.fingers.AddMovement(other, last.Location); // their latest places
|
|
814
|
+
this.fingers.AddMovement(id, args.Location);
|
|
815
|
+
this.multiTouch = true;
|
|
816
|
+
}
|
|
737
817
|
this.activeTouchIds.add(id);
|
|
738
818
|
args.NumberOfTouches = this.activeTouchIds.size;
|
|
739
819
|
args.StartingLocation = args.Location;
|
|
@@ -758,6 +838,8 @@ export class Canvas {
|
|
|
758
838
|
const downArgs = this.pointerDownArgs.get(id);
|
|
759
839
|
args.StartingLocation = downArgs ? downArgs.StartingLocation : args.Location;
|
|
760
840
|
if (args.Type === "Moved") {
|
|
841
|
+
if (this.activeTouchIds.size > 1)
|
|
842
|
+
args.Manipulation = this.fingers.AddMovement(id, args.Location); // nothing for one finger
|
|
761
843
|
const threshold = Canvas.TappedCancelMoveThresholdPoints * Math.max(0.1, this.RenderingScale);
|
|
762
844
|
if (Math.abs(args.Distance.Total.X) >= threshold || Math.abs(args.Distance.Total.Y) >= threshold)
|
|
763
845
|
this.DisarmLongPress(id);
|
|
@@ -770,7 +852,7 @@ export class Canvas {
|
|
|
770
852
|
args.IsInContact = args.NumberOfTouches > 1;
|
|
771
853
|
const longPressed = this.longPressed.delete(id);
|
|
772
854
|
this.DisarmLongPress(id);
|
|
773
|
-
if (!args.IsInContact && downArgs && args.Type === "Released" && !longPressed) {
|
|
855
|
+
if (!args.IsInContact && downArgs && args.Type === "Released" && !longPressed && !this.multiTouch) {
|
|
774
856
|
const threshold = Canvas.TappedCancelMoveThresholdPoints * Math.max(0.1, this.RenderingScale);
|
|
775
857
|
if (Math.abs(args.Distance.Total.X) < threshold && Math.abs(args.Distance.Total.Y) < threshold)
|
|
776
858
|
this.OnGestureEvent(args, "Tapped");
|
|
@@ -779,8 +861,16 @@ export class Canvas {
|
|
|
779
861
|
this.previousTouchArgs.delete(id);
|
|
780
862
|
this.pointerDownArgs.delete(id);
|
|
781
863
|
this.activeTouchIds.delete(id);
|
|
864
|
+
if (this.activeTouchIds.size === 0)
|
|
865
|
+
this.fingers.Reset();
|
|
866
|
+
else
|
|
867
|
+
this.fingers.Lifted(id);
|
|
782
868
|
}
|
|
783
869
|
}
|
|
870
|
+
/** The fingers down, for TouchActionEventArgs.Manipulation (pinch and turn). */
|
|
871
|
+
fingers = new MultitouchTracker();
|
|
872
|
+
/** The press had a second finger: it is no tap (AppoMobi.Blazor.Gestures). */
|
|
873
|
+
multiTouch = false;
|
|
784
874
|
longPressTimers = new Map();
|
|
785
875
|
longPressed = new Set();
|
|
786
876
|
/** The long press of a new press: due LongPressTimeMs later unless the pointer moves away or lets go. */
|
|
@@ -844,25 +934,25 @@ export class Canvas {
|
|
|
844
934
|
return;
|
|
845
935
|
this.arrowsStart = v;
|
|
846
936
|
if (v)
|
|
847
|
-
KeyboardManager.
|
|
937
|
+
KeyboardManager.SubscribeNavigation(this.onArrowKey);
|
|
848
938
|
else
|
|
849
|
-
KeyboardManager.
|
|
939
|
+
KeyboardManager.UnsubscribeNavigation(this.onArrowKey);
|
|
850
940
|
}
|
|
851
|
-
onArrowChar = () => { };
|
|
852
941
|
onArrowKey = (key, e) => {
|
|
853
942
|
const forward = key === "ArrowDown" || key === "ArrowRight" ? true : key === "ArrowUp" || key === "ArrowLeft" ? false : undefined;
|
|
854
943
|
// a page element, a drawn control's element or the editor's input has the keys: nothing to start
|
|
855
944
|
if (forward === undefined || this.disposed || KeyboardManager.IsOwnedByElement(e) || e.defaultPrevented)
|
|
856
|
-
return;
|
|
945
|
+
return false;
|
|
857
946
|
const mgr = this.AccessibilityManager, focused = mgr.FocusedNode;
|
|
858
947
|
if (focused && !mgr.IsOutsideModal(focused))
|
|
859
|
-
return;
|
|
948
|
+
return false;
|
|
860
949
|
const first = mgr.NextTabStop(undefined, forward);
|
|
861
950
|
if (!first)
|
|
862
|
-
return;
|
|
951
|
+
return false;
|
|
863
952
|
e.preventDefault();
|
|
864
953
|
mgr.RequestKeyboardFocus(first);
|
|
865
954
|
this.Update();
|
|
955
|
+
return true;
|
|
866
956
|
};
|
|
867
957
|
// ---- focus (C# DrawnView FocusedChild / ReportFocus, drawnui-cross 6ap) ----
|
|
868
958
|
focusedChild;
|
package/dist/core/Gestures.d.ts
CHANGED
|
@@ -54,6 +54,51 @@ export declare class PointerData {
|
|
|
54
54
|
/** DOM `buttons` bitmask of the buttons held (1 left, 2 right, 4 middle, 8 back, 16 forward). */
|
|
55
55
|
PressedButtons: number;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* AppoMobi.Gestures ManipulationInfo: what two or more fingers did since the previous move, on a Panning while they are
|
|
59
|
+
* down. Pinch to zoom from `Scale`, turn from `Rotation`. Pixels.
|
|
60
|
+
*/
|
|
61
|
+
export declare class ManipulationInfo {
|
|
62
|
+
/** The middle of the fingers now, and at the previous move. */
|
|
63
|
+
readonly Center: SKPoint;
|
|
64
|
+
readonly PreviousCenter: SKPoint;
|
|
65
|
+
/** The fingers' spread now over the previous one, minus 1: 0.05 = 5% further apart. */
|
|
66
|
+
readonly Scale: number;
|
|
67
|
+
/** Degrees the first two fingers turned since the previous move, the short way (never a jump across ±180). */
|
|
68
|
+
readonly Rotation: number;
|
|
69
|
+
/** `Scale` and `Rotation` added up since the number of fingers last changed. */
|
|
70
|
+
readonly ScaleTotal: number;
|
|
71
|
+
readonly RotationTotal: number;
|
|
72
|
+
readonly TouchesCount: number;
|
|
73
|
+
constructor(
|
|
74
|
+
/** The middle of the fingers now, and at the previous move. */
|
|
75
|
+
Center: SKPoint, PreviousCenter: SKPoint,
|
|
76
|
+
/** The fingers' spread now over the previous one, minus 1: 0.05 = 5% further apart. */
|
|
77
|
+
Scale: number,
|
|
78
|
+
/** Degrees the first two fingers turned since the previous move, the short way (never a jump across ±180). */
|
|
79
|
+
Rotation: number,
|
|
80
|
+
/** `Scale` and `Rotation` added up since the number of fingers last changed. */
|
|
81
|
+
ScaleTotal: number, RotationTotal: number, TouchesCount: number);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The fingers down and what they did (AppoMobi.Gestures MultitouchTracker, after Mapsui; as DrawnUi.Rust): their middle,
|
|
85
|
+
* the first one's distance from it, the first two's angle. A new finger count starts the totals again.
|
|
86
|
+
*/
|
|
87
|
+
export declare class MultitouchTracker {
|
|
88
|
+
private readonly fingers;
|
|
89
|
+
private state?;
|
|
90
|
+
private scaleTotal;
|
|
91
|
+
private rotationTotal;
|
|
92
|
+
get Count(): number;
|
|
93
|
+
/** The first finger came down: everything before is forgotten. */
|
|
94
|
+
Restart(id: number, at: SKPoint): void;
|
|
95
|
+
/** A finger came down or moved; what the fingers did while two or more are down and they moved. */
|
|
96
|
+
AddMovement(id: number, at: SKPoint): ManipulationInfo | undefined;
|
|
97
|
+
Lifted(id: number): void;
|
|
98
|
+
Reset(): void;
|
|
99
|
+
private Measure;
|
|
100
|
+
private Calculate;
|
|
101
|
+
}
|
|
57
102
|
/** AppoMobi.Gestures TouchActionEventArgs. */
|
|
58
103
|
export declare class TouchActionEventArgs {
|
|
59
104
|
Id: number;
|
|
@@ -66,6 +111,8 @@ export declare class TouchActionEventArgs {
|
|
|
66
111
|
Distance: DistanceInfo;
|
|
67
112
|
NumberOfTouches: number;
|
|
68
113
|
IsInContact: boolean;
|
|
114
|
+
/** Panning while two or more fingers are down: how they pinched and turned since the previous move. */
|
|
115
|
+
Manipulation?: ManipulationInfo;
|
|
69
116
|
Scale: number;
|
|
70
117
|
Timestamp: number;
|
|
71
118
|
/** ms since the previous event of the same pointer. */
|
package/dist/core/Gestures.js
CHANGED
|
@@ -88,6 +88,97 @@ export class PointerData {
|
|
|
88
88
|
/** DOM `buttons` bitmask of the buttons held (1 left, 2 right, 4 middle, 8 back, 16 forward). */
|
|
89
89
|
PressedButtons = 0;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* AppoMobi.Gestures ManipulationInfo: what two or more fingers did since the previous move, on a Panning while they are
|
|
93
|
+
* down. Pinch to zoom from `Scale`, turn from `Rotation`. Pixels.
|
|
94
|
+
*/
|
|
95
|
+
export class ManipulationInfo {
|
|
96
|
+
Center;
|
|
97
|
+
PreviousCenter;
|
|
98
|
+
Scale;
|
|
99
|
+
Rotation;
|
|
100
|
+
ScaleTotal;
|
|
101
|
+
RotationTotal;
|
|
102
|
+
TouchesCount;
|
|
103
|
+
constructor(
|
|
104
|
+
/** The middle of the fingers now, and at the previous move. */
|
|
105
|
+
Center, PreviousCenter,
|
|
106
|
+
/** The fingers' spread now over the previous one, minus 1: 0.05 = 5% further apart. */
|
|
107
|
+
Scale,
|
|
108
|
+
/** Degrees the first two fingers turned since the previous move, the short way (never a jump across ±180). */
|
|
109
|
+
Rotation,
|
|
110
|
+
/** `Scale` and `Rotation` added up since the number of fingers last changed. */
|
|
111
|
+
ScaleTotal, RotationTotal, TouchesCount) {
|
|
112
|
+
this.Center = Center;
|
|
113
|
+
this.PreviousCenter = PreviousCenter;
|
|
114
|
+
this.Scale = Scale;
|
|
115
|
+
this.Rotation = Rotation;
|
|
116
|
+
this.ScaleTotal = ScaleTotal;
|
|
117
|
+
this.RotationTotal = RotationTotal;
|
|
118
|
+
this.TouchesCount = TouchesCount;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The fingers down and what they did (AppoMobi.Gestures MultitouchTracker, after Mapsui; as DrawnUi.Rust): their middle,
|
|
123
|
+
* the first one's distance from it, the first two's angle. A new finger count starts the totals again.
|
|
124
|
+
*/
|
|
125
|
+
export class MultitouchTracker {
|
|
126
|
+
fingers = new Map();
|
|
127
|
+
state;
|
|
128
|
+
scaleTotal = 0;
|
|
129
|
+
rotationTotal = 0;
|
|
130
|
+
get Count() { return this.fingers.size; }
|
|
131
|
+
/** The first finger came down: everything before is forgotten. */
|
|
132
|
+
Restart(id, at) {
|
|
133
|
+
this.fingers.clear();
|
|
134
|
+
this.fingers.set(id, at);
|
|
135
|
+
this.scaleTotal = this.rotationTotal = 0;
|
|
136
|
+
this.state = this.Measure();
|
|
137
|
+
}
|
|
138
|
+
/** A finger came down or moved; what the fingers did while two or more are down and they moved. */
|
|
139
|
+
AddMovement(id, at) {
|
|
140
|
+
this.fingers.set(id, at);
|
|
141
|
+
return this.Calculate();
|
|
142
|
+
}
|
|
143
|
+
Lifted(id) { if (this.fingers.delete(id))
|
|
144
|
+
this.Calculate(); }
|
|
145
|
+
Reset() { this.fingers.clear(); this.state = undefined; }
|
|
146
|
+
Measure() {
|
|
147
|
+
const points = [...this.fingers.values()];
|
|
148
|
+
if (points.length === 0)
|
|
149
|
+
return undefined;
|
|
150
|
+
const first = points[0];
|
|
151
|
+
if (points.length === 1)
|
|
152
|
+
return { Center: first, Radius: 0, Angle: 0, Count: 1 };
|
|
153
|
+
let x = 0, y = 0;
|
|
154
|
+
for (const p of points) {
|
|
155
|
+
x += p.X;
|
|
156
|
+
y += p.Y;
|
|
157
|
+
}
|
|
158
|
+
const center = new SKPoint(x / points.length, y / points.length), second = points[1];
|
|
159
|
+
return {
|
|
160
|
+
Center: center, Radius: Math.hypot(first.X - center.X, first.Y - center.Y),
|
|
161
|
+
Angle: (Math.atan2(second.Y - first.Y, second.X - first.X) * 180) / Math.PI, Count: points.length,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
Calculate() {
|
|
165
|
+
const now = this.Measure(), previous = this.state;
|
|
166
|
+
this.state = now;
|
|
167
|
+
if (!now || !previous || now.Count < 2)
|
|
168
|
+
return undefined;
|
|
169
|
+
if (now.Count !== previous.Count) {
|
|
170
|
+
this.scaleTotal = this.rotationTotal = 0;
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
const scale = previous.Radius > 0 && now.Radius !== previous.Radius ? now.Radius / previous.Radius - 1 : 0;
|
|
174
|
+
const rotation = ((((now.Angle - previous.Angle + 540) % 360) + 360) % 360) - 180;
|
|
175
|
+
this.scaleTotal += scale;
|
|
176
|
+
this.rotationTotal += rotation;
|
|
177
|
+
if (now.Center.X === previous.Center.X && now.Center.Y === previous.Center.Y && now.Radius === previous.Radius && now.Angle === previous.Angle)
|
|
178
|
+
return undefined;
|
|
179
|
+
return new ManipulationInfo(now.Center, previous.Center, scale, rotation, this.scaleTotal, this.rotationTotal, now.Count);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
91
182
|
/** AppoMobi.Gestures TouchActionEventArgs. */
|
|
92
183
|
export class TouchActionEventArgs {
|
|
93
184
|
Id = 0;
|
|
@@ -100,6 +191,8 @@ export class TouchActionEventArgs {
|
|
|
100
191
|
Distance = new DistanceInfo();
|
|
101
192
|
NumberOfTouches = 1;
|
|
102
193
|
IsInContact = false;
|
|
194
|
+
/** Panning while two or more fingers are down: how they pinched and turned since the previous move. */
|
|
195
|
+
Manipulation;
|
|
103
196
|
Scale = 1;
|
|
104
197
|
Timestamp = performance.now();
|
|
105
198
|
/** ms since the previous event of the same pointer. */
|