react-native-smooth-clip-view 0.2.2 → 0.2.5

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.
Files changed (44) hide show
  1. package/README.md +52 -14
  2. package/android/CMakeLists.txt +4 -0
  3. package/android/build.gradle +1 -0
  4. package/android/src/main/cpp/SmoothClipRegistry.cpp +72 -53
  5. package/cpp/SmoothClipVelocityTracker.h +101 -0
  6. package/ios/SmoothClipView.mm +32 -74
  7. package/lib/module/drivers.android.js +3 -1
  8. package/lib/module/drivers.android.js.map +1 -1
  9. package/lib/module/drivers.ios.js +3 -377
  10. package/lib/module/drivers.ios.js.map +1 -1
  11. package/lib/module/drivers.js +8 -0
  12. package/lib/module/drivers.js.map +1 -1
  13. package/lib/module/drivers.native.js +401 -0
  14. package/lib/module/drivers.native.js.map +1 -0
  15. package/lib/module/easings.js +35 -0
  16. package/lib/module/easings.js.map +1 -0
  17. package/lib/module/index.js +1 -0
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/index.web.js +1 -0
  20. package/lib/module/index.web.js.map +1 -1
  21. package/lib/typescript/src/driverTypes.d.ts +34 -3
  22. package/lib/typescript/src/driverTypes.d.ts.map +1 -1
  23. package/lib/typescript/src/drivers.android.d.ts +2 -2
  24. package/lib/typescript/src/drivers.android.d.ts.map +1 -1
  25. package/lib/typescript/src/drivers.d.ts.map +1 -1
  26. package/lib/typescript/src/drivers.ios.d.ts +2 -4
  27. package/lib/typescript/src/drivers.ios.d.ts.map +1 -1
  28. package/lib/typescript/src/drivers.native.d.ts +5 -0
  29. package/lib/typescript/src/drivers.native.d.ts.map +1 -0
  30. package/lib/typescript/src/easings.d.ts +33 -0
  31. package/lib/typescript/src/easings.d.ts.map +1 -0
  32. package/lib/typescript/src/index.d.ts +1 -0
  33. package/lib/typescript/src/index.d.ts.map +1 -1
  34. package/lib/typescript/src/index.web.d.ts +1 -0
  35. package/lib/typescript/src/index.web.d.ts.map +1 -1
  36. package/package.json +1 -1
  37. package/src/driverTypes.ts +53 -19
  38. package/src/drivers.android.ts +4 -2
  39. package/src/drivers.ios.ts +4 -661
  40. package/src/drivers.native.ts +698 -0
  41. package/src/drivers.ts +11 -0
  42. package/src/easings.ts +32 -0
  43. package/src/index.ts +1 -0
  44. package/src/index.web.ts +1 -0
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Exact cubic-Bézier control points for the standard polynomial easings, for
3
+ * use as `TimingClipAnimation.controlPoints`.
4
+ *
5
+ * Native transitions and a parallel Reanimated animation (content driven by
6
+ * `withTiming` alongside a native `animateTo`) only stay in sync when both
7
+ * sides run the identical curve. Each entry below is the exact single-Bézier
8
+ * form of the matching Reanimated easing — not an approximation — so pairing
9
+ * e.g. `Easing.out(Easing.cubic)` with `ClipEasings.easeOutCubic` is
10
+ * mathematically lossless:
11
+ *
12
+ * - `linear` ↔ `Easing.linear`
13
+ * - `easeInQuad` ↔ `Easing.in(Easing.quad)`
14
+ * - `easeOutQuad` ↔ `Easing.out(Easing.quad)`
15
+ * - `easeInCubic` ↔ `Easing.in(Easing.cubic)`
16
+ * - `easeOutCubic` ↔ `Easing.out(Easing.cubic)`
17
+ *
18
+ * With x-control-points at 1/3 and 2/3 the Bézier's x(t) is the identity, so
19
+ * y(t) is the easing polynomial itself (e.g. `easeOutCubic`: y = 1 − (1−t)³).
20
+ *
21
+ * `Easing.inOut(Easing.cubic)` (and the other `inOut` polynomials) are
22
+ * piecewise and have NO exact single-Bézier form — for those, define one
23
+ * `Easing.bezier(x1, y1, x2, y2)` and pass the same four numbers as
24
+ * `controlPoints` so both sides share the same (approximated) curve.
25
+ */
26
+ export declare const ClipEasings: {
27
+ readonly linear: readonly [0, 0, 1, 1];
28
+ readonly easeInQuad: readonly [number, 0, number, number];
29
+ readonly easeOutQuad: readonly [number, number, number, 1];
30
+ readonly easeInCubic: readonly [number, 0, number, 0];
31
+ readonly easeOutCubic: readonly [number, 1, number, 1];
32
+ };
33
+ //# sourceMappingURL=easings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"easings.d.ts","sourceRoot":"","sources":["../../../src/easings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,WAAW;;;;;;CAMsD,CAAC"}
@@ -2,6 +2,7 @@ export { SmoothClipView } from './SmoothClipView';
2
2
  export type { SmoothClipViewProps } from './SmoothClipView';
3
3
  export { useSmoothClipDriver } from './drivers';
4
4
  export type { ClipAnimationResult, ClipReduceMotion, KeyframedClipAnimation, SmoothClipDriver, SmoothClipDriverOptions, SmoothClipReactControls, SmoothClipUIControls, SmoothClipAnimation, SpringClipAnimation, TimingClipAnimation, } from './driverTypes.js';
5
+ export { ClipEasings } from './easings.js';
5
6
  export { normalizeClipGeometry } from './geometry.js';
6
7
  export { createClipPresentation } from './geometry.js';
7
8
  export type { ClipBounds, ClipGeometry, SmoothClipPresentation, } from './geometry.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAY,CAAC;AACpD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,GACvB,MAAM,eAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAW,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAY,CAAC;AACpD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,GACvB,MAAM,eAAY,CAAC"}
@@ -2,6 +2,7 @@ export { SmoothClipView } from './SmoothClipView.web.js';
2
2
  export type { SmoothClipViewProps } from './SmoothClipView.web.js';
3
3
  export { useSmoothClipDriver } from './drivers';
4
4
  export type { ClipAnimationResult, ClipReduceMotion, KeyframedClipAnimation, SmoothClipDriver, SmoothClipDriverOptions, SmoothClipReactControls, SmoothClipUIControls, SmoothClipAnimation, SpringClipAnimation, TimingClipAnimation, } from './driverTypes.js';
5
+ export { ClipEasings } from './easings.js';
5
6
  export { normalizeClipGeometry } from './geometry.js';
6
7
  export { createClipPresentation } from './geometry.js';
7
8
  export type { ClipBounds, ClipGeometry, SmoothClipPresentation, } from './geometry.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../src/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAsB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAsB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAY,CAAC;AACpD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,GACvB,MAAM,eAAY,CAAC"}
1
+ {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../src/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAsB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAsB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAW,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAY,CAAC;AACpD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,GACvB,MAAM,eAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-smooth-clip-view",
3
- "version": "0.2.2",
3
+ "version": "0.2.5",
4
4
  "description": "Layout-free animated rounded clipping for React Native Fabric",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -3,28 +3,59 @@ import type { SmoothClipPresentation } from './geometry';
3
3
 
4
4
  export type ClipReduceMotion = 'system' | 'always' | 'never';
5
5
 
6
- export type TimingClipAnimation = Readonly<{
7
- type: 'timing';
8
- duration: number;
9
- controlPoints: readonly [number, number, number, number];
6
+ /** Options shared by every animation kind. */
7
+ type ClipAnimationBase = Readonly<{
8
+ /**
9
+ * Explicit start: fuses a `setScalars(from…)` take-ownership hot write
10
+ * immediately before the animation, so native starts from exactly this
11
+ * presentation instead of its last delivered value. Use at a gesture
12
+ * release when the freshest sample (e.g. the UP event's position) never
13
+ * reached native — a gated per-frame reaction may not have flushed it.
14
+ * Also re-grabs from a running animation (which an implicit interactive
15
+ * start would silently skip). Non-finite `from` rejects the whole call.
16
+ * On the native drivers `driver.presentation.value` is not written from
17
+ * `from` (it stays stale until success sets it to the target); the web
18
+ * fallback does write it — its presentation SharedValue is the render
19
+ * channel itself. Against a held pending-animation latch the seed is
20
+ * dropped by design — latch intent wins.
21
+ *
22
+ * Keyframes interpolate absolutely, so pass `frames[0].presentation` —
23
+ * the seed renders it before the first animation frame, making the
24
+ * handoff continuous.
25
+ *
26
+ * iOS note: keyframes start exactly at `from` (frame 0 travels in-band);
27
+ * timing/spring sample their Core Animation from-value off the
28
+ * presentation layer — the last committed frame, at most one frame behind
29
+ * `from` — identical to the two-call pattern this option desugars to.
30
+ */
31
+ from?: SmoothClipPresentation;
10
32
  }>;
11
33
 
12
- export type SpringClipAnimation = Readonly<{
13
- type: 'spring';
14
- mass?: number;
15
- stiffness?: number;
16
- damping?: number;
17
- initialVelocity?: number | 'inherit';
18
- }>;
34
+ export type TimingClipAnimation = ClipAnimationBase &
35
+ Readonly<{
36
+ type: 'timing';
37
+ duration: number;
38
+ controlPoints: readonly [number, number, number, number];
39
+ }>;
19
40
 
20
- export type KeyframedClipAnimation = Readonly<{
21
- type: 'keyframes';
22
- duration: number;
23
- frames: readonly Readonly<{
24
- offset: number;
25
- presentation: SmoothClipPresentation;
26
- }>[];
27
- }>;
41
+ export type SpringClipAnimation = ClipAnimationBase &
42
+ Readonly<{
43
+ type: 'spring';
44
+ mass?: number;
45
+ stiffness?: number;
46
+ damping?: number;
47
+ initialVelocity?: number | 'inherit';
48
+ }>;
49
+
50
+ export type KeyframedClipAnimation = ClipAnimationBase &
51
+ Readonly<{
52
+ type: 'keyframes';
53
+ duration: number;
54
+ frames: readonly Readonly<{
55
+ offset: number;
56
+ presentation: SmoothClipPresentation;
57
+ }>[];
58
+ }>;
28
59
 
29
60
  export type SmoothClipAnimation =
30
61
  TimingClipAnimation | SpringClipAnimation | KeyframedClipAnimation;
@@ -50,6 +81,9 @@ export type SmoothClipUIControls = Readonly<{
50
81
  * `beginInteraction()` remains the source of truth for visible geometry.
51
82
  * Do not interleave with `presentation.value` writes on the same driver —
52
83
  * the listener's duplicate suppression may skip a later equal value.
84
+ * To hand off into an animation from a fresher value than the last hot
85
+ * write, pass the geometry as `animation.from` to `animateTo` — it fuses
86
+ * this call and the handoff into one.
53
87
  */
54
88
  setScalars(
55
89
  x: number,
@@ -1,6 +1,8 @@
1
- export { useSmoothClipDriver } from './drivers.ios';
1
+ // Platform re-export only — the implementation is shared with iOS.
2
+ // Edit drivers.native.ts, not this file.
3
+ export { useSmoothClipDriver } from './drivers.native';
2
4
  export type {
3
5
  KeyframedClipAnimation,
4
6
  SpringClipAnimation,
5
7
  TimingClipAnimation,
6
- } from './drivers.ios';
8
+ } from './drivers.native';