drawnui-react 0.1.0-preview.38 → 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
CHANGED
|
@@ -49,6 +49,13 @@ property names, layout and drawing rules. What you learn here works there, and s
|
|
|
49
49
|
|
|
50
50
|
DrawnUI is MIT licensed in every language and on every platform: desktop, mobile, web and embedded devices. Ship it in commercial products with no attribution badge, no about screen and no per-device royalty.
|
|
51
51
|
|
|
52
|
+
## What's new in 0.1.0-preview.39
|
|
53
|
+
|
|
54
|
+
- **Tap feedback for the primary pointer:** tap and press animations (`AnimationTapped="Ripple"`, `SkiaButton`'s press
|
|
55
|
+
ripple, a tappable span's ripple) play for a finger, a pen or the left mouse button. A right or middle click raises its
|
|
56
|
+
events as before (`Tapped` with `Button` `"Right"`, `ContextMenu`) with no ripple. `SkiaControl.IsPrimaryPointer(args)`
|
|
57
|
+
tells your own controls the same.
|
|
58
|
+
|
|
52
59
|
## What's new in 0.1.0-preview.38
|
|
53
60
|
|
|
54
61
|
- **SkiaScroll size, as in DrawnUI for .NET and Rust:** a `SkiaScroll` without a `WidthRequest` / `HeightRequest` that
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Path } from "canvaskit-wasm";
|
|
2
|
-
import
|
|
2
|
+
import { SkiaControl } from "../core/SkiaControl";
|
|
3
3
|
import { type Color, type CornerRadius, ScaledSize, type SkiaTouchAnimation } from "../core/Types";
|
|
4
4
|
import { type GestureEventProcessingInfo, type SkiaGesturesParameters } from "../core/Gestures";
|
|
5
5
|
import { SkiaLayout } from "./SkiaLayout";
|
|
@@ -69,7 +69,7 @@ export declare class SkiaButton extends SkiaLayout {
|
|
|
69
69
|
/** Ripple clipped to the rounded frame. */
|
|
70
70
|
CreateClip(): Path;
|
|
71
71
|
/** DrawnUi SkiaButton.OnDown: press feedback; true = consume Down. */
|
|
72
|
-
protected OnDown(
|
|
72
|
+
protected OnDown(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): boolean;
|
|
73
73
|
private SetUp;
|
|
74
74
|
ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
75
75
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SkiaControl } from "../core/SkiaControl";
|
|
1
2
|
import { Colors, SKRect, ScaledSize, SkiaShadow, Thickness } from "../core/Types";
|
|
2
3
|
import { SKPoint } from "../core/Gestures";
|
|
3
4
|
import { SkiaLayout } from "./SkiaLayout";
|
|
@@ -129,8 +130,8 @@ export class SkiaButton extends SkiaLayout {
|
|
|
129
130
|
/** Ripple clipped to the rounded frame. */
|
|
130
131
|
CreateClip() { return this.frame.CreateClip(); }
|
|
131
132
|
/** DrawnUi SkiaButton.OnDown: press feedback; true = consume Down. */
|
|
132
|
-
OnDown(
|
|
133
|
-
if (this.ApplyEffect === "Ripple") {
|
|
133
|
+
OnDown(args, apply) {
|
|
134
|
+
if (this.ApplyEffect === "Ripple" && SkiaControl.IsPrimaryPointer(args)) {
|
|
134
135
|
const pts = this.GetOffsetInsideControlInPoints(apply.MappedLocation, apply.ChildOffset);
|
|
135
136
|
this.PlayRippleAnimation(this.TouchEffectColor, pts.X, pts.Y);
|
|
136
137
|
}
|
|
@@ -1010,7 +1010,8 @@ export class SkiaLabel extends SkiaControl {
|
|
|
1010
1010
|
const y = apply.MappedLocation.Y + apply.ChildOffset.Y - this.DrawingRect.Top;
|
|
1011
1011
|
for (const span of this.Spans) {
|
|
1012
1012
|
if (span.HasTapHandler && span.HitIsInside(x, y)) {
|
|
1013
|
-
|
|
1013
|
+
if (SkiaControl.IsPrimaryPointer(args))
|
|
1014
|
+
this.PlayRippleAnimation(this.TouchEffectColor, x / this.RenderingScale, y / this.RenderingScale);
|
|
1014
1015
|
return this.OnSpanTapped(span, args, apply);
|
|
1015
1016
|
}
|
|
1016
1017
|
}
|
|
@@ -668,6 +668,11 @@ export declare class SkiaControl {
|
|
|
668
668
|
* ConsumeGestures hook -> children top-most first -> own Tapped. Returns the consumer or null.
|
|
669
669
|
*/
|
|
670
670
|
ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
671
|
+
/**
|
|
672
|
+
* The gesture comes from a finger, a pen or the primary (left) mouse button (C# IsPrimaryPointer). Tap and press
|
|
673
|
+
* animations (Ripple) play only for those: a right or middle click raises its events but shows no tap feedback.
|
|
674
|
+
*/
|
|
675
|
+
static IsPrimaryPointer(args: SkiaGesturesParameters): boolean;
|
|
671
676
|
/** Fires Tapped (after AnimationTapped feedback); true when a handler existed (= consumed), like DrawnUi SendTapped. */
|
|
672
677
|
protected SendTapped(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): boolean;
|
|
673
678
|
/** Canvas-pixel touch location -> points relative to this control's top-left. */
|
package/dist/core/SkiaControl.js
CHANGED
|
@@ -1747,11 +1747,16 @@ export class SkiaControl {
|
|
|
1747
1747
|
return this;
|
|
1748
1748
|
return consumed ?? consumedDefault;
|
|
1749
1749
|
}
|
|
1750
|
+
/**
|
|
1751
|
+
* The gesture comes from a finger, a pen or the primary (left) mouse button (C# IsPrimaryPointer). Tap and press
|
|
1752
|
+
* animations (Ripple) play only for those: a right or middle click raises its events but shows no tap feedback.
|
|
1753
|
+
*/
|
|
1754
|
+
static IsPrimaryPointer(args) { return (args.Event.Pointer?.Button ?? "Left") === "Left"; }
|
|
1750
1755
|
/** Fires Tapped (after AnimationTapped feedback); true when a handler existed (= consumed), like DrawnUi SendTapped. */
|
|
1751
1756
|
SendTapped(args, apply) {
|
|
1752
1757
|
if (!this.Tapped)
|
|
1753
1758
|
return false;
|
|
1754
|
-
if (this.AnimationTapped === "Ripple") {
|
|
1759
|
+
if (this.AnimationTapped === "Ripple" && SkiaControl.IsPrimaryPointer(args)) {
|
|
1755
1760
|
const pts = this.GetOffsetInsideControlInPoints(apply.MappedLocation, apply.ChildOffset);
|
|
1756
1761
|
this.PlayRippleAnimation(this.TouchEffectColor, pts.X, pts.Y, true, this.AnimationTappedSpeed);
|
|
1757
1762
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drawnui-react",
|
|
3
|
-
"version": "0.1.0-preview.
|
|
3
|
+
"version": "0.1.0-preview.39",
|
|
4
4
|
"description": "DrawnUi for React: the DrawnUi (.NET) drawn-UI engine in TypeScript on CanvasKit (Skia WASM). Same controls, same PascalCase API as DrawnUi.Net.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nick Kovalsky (AppoMobi)",
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"check:shell-modal": "node dev/check.mjs dev/check-shell-modal.tsx",
|
|
105
105
|
"check:multitouch": "node dev/check.mjs dev/check-multitouch.ts",
|
|
106
106
|
"check:scroll-size": "node dev/check.mjs dev/check-scroll-size.ts",
|
|
107
|
+
"check:ripple-primary": "node dev/check.mjs dev/check-ripple-primary.ts",
|
|
107
108
|
"audit:a11y": "node dev/audit-a11y.mjs",
|
|
108
109
|
"bench:relayout": "node dev/check.mjs dev/bench-relayout.ts",
|
|
109
110
|
"site:extras": "node dev/site-extras.mjs dist/demo",
|