@sigx/lynx-gestures 0.4.7 → 0.4.9
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pressable.d.ts","sourceRoot":"","sources":["../../src/components/Pressable.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Pressable.d.ts","sourceRoot":"","sources":["../../src/components/Pressable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,MAAM,EAEZ,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,cAAc,GACtB,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,EAAE,KAAK,CAAC,GAC5C,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,GAC1C,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,EAAE,KAAK,CAAC,GAC/C,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,GACzC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,GACvC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,GACnC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,CAAC,GAO5D,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE,KAAK,CAAC,GACpD,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,MAAM,EAAE,KAAK,CAAC,GACjD,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE,KAAK,CAAC,GAChD,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,MAAM,EAAE,KAAK,CAAC,GACjD,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,MAAM,EAAE,KAAK,CAAC,GAClD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GACtB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,GAC3B,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AASpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,SAAS;;EAiJpB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
|
|
2
|
-
import { component, useMainThreadRef, runOnBackground, Gesture, useGestureDetector, } from '@sigx/lynx';
|
|
2
|
+
import { component, useMainThreadRef, runOnMainThread, runOnBackground, Gesture, useGestureDetector, } from '@sigx/lynx';
|
|
3
3
|
/**
|
|
4
4
|
* MT-thread tap + long-press recognizer with built-in pressed-state visual
|
|
5
5
|
* feedback (opacity + scale). Press and long-press callbacks are dispatched
|
|
@@ -49,8 +49,15 @@ export const Pressable = component(({ props, slots, emit }) => {
|
|
|
49
49
|
const maxDistanceSq = maxDistance * maxDistance;
|
|
50
50
|
// Reactive `disabled` — worklets read `disabledRef.current` so prop
|
|
51
51
|
// changes after mount take effect without re-registering the gesture.
|
|
52
|
-
// The
|
|
52
|
+
// The MT-side copy is seeded once (INIT_MT_REF) from the value below;
|
|
53
|
+
// BG-side `.current` writes do NOT cross threads, so the render fn ships
|
|
54
|
+
// changes over via the `syncDisabled` worklet.
|
|
53
55
|
const disabledRef = useMainThreadRef(!!props.disabled);
|
|
56
|
+
const syncDisabled = runOnMainThread((v) => {
|
|
57
|
+
'main thread';
|
|
58
|
+
disabledRef.current = v;
|
|
59
|
+
});
|
|
60
|
+
let lastDisabled = !!props.disabled;
|
|
54
61
|
const state = useMainThreadRef({
|
|
55
62
|
longPressFired: false,
|
|
56
63
|
pressEmitted: false,
|
|
@@ -148,9 +155,16 @@ export const Pressable = component(({ props, slots, emit }) => {
|
|
|
148
155
|
const gesture = Gesture.Simultaneous(tap, longPress);
|
|
149
156
|
useGestureDetector(elRef, gesture);
|
|
150
157
|
return () => {
|
|
151
|
-
// Keep the reactive-disabled ref in sync with the prop
|
|
152
|
-
//
|
|
153
|
-
|
|
158
|
+
// Keep the MT-side reactive-disabled ref in sync with the prop. A plain
|
|
159
|
+
// BG-side `disabledRef.current = …` write never reaches MT (the BG copy
|
|
160
|
+
// is a read-only snapshot of the initial value), so a Pressable mounted
|
|
161
|
+
// disabled would stay dead at the gesture layer forever. Ship changes
|
|
162
|
+
// across with the runOnMainThread worklet instead.
|
|
163
|
+
const d = !!props.disabled;
|
|
164
|
+
if (d !== lastDisabled) {
|
|
165
|
+
lastDisabled = d;
|
|
166
|
+
void syncDisabled(d);
|
|
167
|
+
}
|
|
154
168
|
return (_jsx("view", { class: props.class, style: props.style, "main-thread:ref": elRef, "accessibility-element": props['accessibility-element'], "accessibility-label": props['accessibility-label'], "accessibility-role": props['accessibility-role'], "accessibility-trait": props['accessibility-trait'], "accessibility-status": props['accessibility-status'], children: slots.default?.() }));
|
|
155
169
|
};
|
|
156
170
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pressable.js","sourceRoot":"","sources":["../../src/components/Pressable.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,OAAO,EACP,kBAAkB,GAGnB,MAAM,YAAY,CAAC;AAgCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;IAC5E,MAAM,KAAK,GAAG,gBAAgB,CAA4B,IAAI,CAAC,CAAC;IAEhE,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,IAAI,GAAG,CAAC;IAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,IAAI,CAAC,CAA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wEAAwE;QACxE,sEAAsE;QACtE,mDAAmD;QACnD,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC3B,IAAI,CAAC,KAAK,YAAY,EAAE,CAAC;YACvB,YAAY,GAAG,CAAC,CAAC;YACjB,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,CACL,eACE,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK,qBACD,KAAK,2BACC,KAAK,CAAC,uBAAuB,CAAC,yBAChC,KAAK,CAAC,qBAAqB,CAAC,wBAC7B,KAAK,CAAC,oBAAoB,CAAC,yBAC1B,KAAK,CAAC,qBAAqB,CAAC,0BAC3B,KAAK,CAAC,sBAAsB,CAAC,YAElD,KAAK,CAAC,OAAO,EAAE,EAAE,GACb,CACR,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigx/lynx-gestures",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "Gesture system for sigx-lynx - declarative composables for tap, pan, pinch, swipe, long press",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"author": "Andreas Ekdahl",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@sigx/lynx": "^0.4.
|
|
31
|
+
"@sigx/lynx": "^0.4.9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@lynx-js/react": "^0.121.0",
|
|
35
35
|
"@typescript/native-preview": "7.0.0-dev.20260521.1",
|
|
36
36
|
"typescript": "^6.0.3",
|
|
37
|
-
"@sigx/lynx-
|
|
38
|
-
"@sigx/lynx-
|
|
39
|
-
"@sigx/lynx-testing": "^0.4.
|
|
37
|
+
"@sigx/lynx-runtime-main": "^0.4.9",
|
|
38
|
+
"@sigx/lynx-plugin": "^0.4.9",
|
|
39
|
+
"@sigx/lynx-testing": "^0.4.9"
|
|
40
40
|
},
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
component,
|
|
3
3
|
useMainThreadRef,
|
|
4
|
+
runOnMainThread,
|
|
4
5
|
runOnBackground,
|
|
5
6
|
Gesture,
|
|
6
7
|
useGestureDetector,
|
|
@@ -89,8 +90,15 @@ export const Pressable = component<PressableProps>(({ props, slots, emit }) => {
|
|
|
89
90
|
|
|
90
91
|
// Reactive `disabled` — worklets read `disabledRef.current` so prop
|
|
91
92
|
// changes after mount take effect without re-registering the gesture.
|
|
92
|
-
// The
|
|
93
|
+
// The MT-side copy is seeded once (INIT_MT_REF) from the value below;
|
|
94
|
+
// BG-side `.current` writes do NOT cross threads, so the render fn ships
|
|
95
|
+
// changes over via the `syncDisabled` worklet.
|
|
93
96
|
const disabledRef = useMainThreadRef<boolean>(!!props.disabled);
|
|
97
|
+
const syncDisabled = runOnMainThread((v: boolean) => {
|
|
98
|
+
'main thread';
|
|
99
|
+
disabledRef.current = v;
|
|
100
|
+
});
|
|
101
|
+
let lastDisabled = !!props.disabled;
|
|
94
102
|
|
|
95
103
|
const state = useMainThreadRef<PressableMTState>({
|
|
96
104
|
longPressFired: false,
|
|
@@ -186,9 +194,16 @@ export const Pressable = component<PressableProps>(({ props, slots, emit }) => {
|
|
|
186
194
|
useGestureDetector(elRef, gesture);
|
|
187
195
|
|
|
188
196
|
return () => {
|
|
189
|
-
// Keep the reactive-disabled ref in sync with the prop
|
|
190
|
-
//
|
|
191
|
-
|
|
197
|
+
// Keep the MT-side reactive-disabled ref in sync with the prop. A plain
|
|
198
|
+
// BG-side `disabledRef.current = …` write never reaches MT (the BG copy
|
|
199
|
+
// is a read-only snapshot of the initial value), so a Pressable mounted
|
|
200
|
+
// disabled would stay dead at the gesture layer forever. Ship changes
|
|
201
|
+
// across with the runOnMainThread worklet instead.
|
|
202
|
+
const d = !!props.disabled;
|
|
203
|
+
if (d !== lastDisabled) {
|
|
204
|
+
lastDisabled = d;
|
|
205
|
+
void syncDisabled(d);
|
|
206
|
+
}
|
|
192
207
|
return (
|
|
193
208
|
<view
|
|
194
209
|
class={props.class}
|