react-native-smooth-clip-view 0.1.0 → 0.2.1
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 +171 -43
- package/SmoothClipView.podspec +8 -2
- package/android/CMakeLists.txt +39 -0
- package/android/build.gradle +69 -2
- package/android/proguard-rules.pro +6 -0
- package/android/src/main/cpp/SmoothClipAndroid.h +59 -0
- package/android/src/main/cpp/SmoothClipBindings.cpp +428 -0
- package/android/src/main/cpp/SmoothClipRegistry.cpp +945 -0
- package/android/src/main/java/com/smoothclipview/ClipGeometryNormalizer.kt +25 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipBindings.kt +55 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipModule.kt +128 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipView.kt +164 -30
- package/android/src/main/java/com/smoothclipview/SmoothClipViewManager.kt +107 -10
- package/android/src/main/java/com/smoothclipview/SmoothClipViewPackage.kt +18 -2
- package/cpp/SmoothClipRegistry.h +93 -0
- package/cpp/SmoothClipSharedGeometry.h +50 -0
- package/ios/SmoothClipModuleProvider.h +9 -0
- package/ios/SmoothClipModuleProvider.mm +16 -0
- package/ios/SmoothClipRegistry.mm +754 -0
- package/ios/SmoothClipTurboModule.cpp +290 -0
- package/ios/SmoothClipTurboModule.h +132 -0
- package/ios/SmoothClipView.mm +976 -85
- package/ios/SmoothClipViewRegistry.h +27 -0
- package/lib/module/NativeSmoothClipModule.js +5 -0
- package/lib/module/NativeSmoothClipModule.js.map +1 -0
- package/lib/module/SmoothClipView.android.js +4 -0
- package/lib/module/SmoothClipView.android.js.map +1 -0
- package/lib/module/SmoothClipView.ios.js +34 -0
- package/lib/module/SmoothClipView.ios.js.map +1 -0
- package/lib/module/SmoothClipView.js +26 -12
- package/lib/module/SmoothClipView.js.map +1 -1
- package/lib/module/SmoothClipView.web.js +28 -12
- package/lib/module/SmoothClipView.web.js.map +1 -1
- package/lib/module/SmoothClipViewNativeComponent.ts +14 -1
- package/lib/module/driverState.js +102 -0
- package/lib/module/driverState.js.map +1 -0
- package/lib/module/driverTypes.js +4 -0
- package/lib/module/driverTypes.js.map +1 -0
- package/lib/module/drivers.android.js +4 -0
- package/lib/module/drivers.android.js.map +1 -0
- package/lib/module/drivers.ios.js +380 -0
- package/lib/module/drivers.ios.js.map +1 -0
- package/lib/module/drivers.js +276 -0
- package/lib/module/drivers.js.map +1 -0
- package/lib/module/geometry.js +19 -0
- package/lib/module/geometry.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +2 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/nativeCompletion.js +21 -0
- package/lib/module/nativeCompletion.js.map +1 -0
- package/lib/module/reactRequests.js +50 -0
- package/lib/module/reactRequests.js.map +1 -0
- package/lib/module/smoothClipNative.android.js +15 -0
- package/lib/module/smoothClipNative.android.js.map +1 -0
- package/lib/module/smoothClipNative.js +8 -0
- package/lib/module/smoothClipNative.js.map +1 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts +19 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts.map +1 -0
- package/lib/typescript/src/SmoothClipView.android.d.ts +3 -0
- package/lib/typescript/src/SmoothClipView.android.d.ts.map +1 -0
- package/lib/typescript/src/SmoothClipView.d.ts +5 -6
- package/lib/typescript/src/SmoothClipView.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipView.ios.d.ts +9 -0
- package/lib/typescript/src/SmoothClipView.ios.d.ts.map +1 -0
- package/lib/typescript/src/SmoothClipView.web.d.ts +5 -7
- package/lib/typescript/src/SmoothClipView.web.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts +4 -0
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/driverState.d.ts +31 -0
- package/lib/typescript/src/driverState.d.ts.map +1 -0
- package/lib/typescript/src/driverTypes.d.ts +61 -0
- package/lib/typescript/src/driverTypes.d.ts.map +1 -0
- package/lib/typescript/src/drivers.android.d.ts +3 -0
- package/lib/typescript/src/drivers.android.d.ts.map +1 -0
- package/lib/typescript/src/drivers.d.ts +5 -0
- package/lib/typescript/src/drivers.d.ts.map +1 -0
- package/lib/typescript/src/drivers.ios.d.ts +5 -0
- package/lib/typescript/src/drivers.ios.d.ts.map +1 -0
- package/lib/typescript/src/geometry.d.ts +8 -0
- package/lib/typescript/src/geometry.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +4 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/nativeCompletion.d.ts +7 -0
- package/lib/typescript/src/nativeCompletion.d.ts.map +1 -0
- package/lib/typescript/src/reactRequests.d.ts +7 -0
- package/lib/typescript/src/reactRequests.d.ts.map +1 -0
- package/lib/typescript/src/smoothClipNative.android.d.ts +4 -0
- package/lib/typescript/src/smoothClipNative.android.d.ts.map +1 -0
- package/lib/typescript/src/smoothClipNative.d.ts +3 -0
- package/lib/typescript/src/smoothClipNative.d.ts.map +1 -0
- package/package.json +12 -7
- package/src/NativeSmoothClipModule.ts +104 -0
- package/src/SmoothClipView.android.tsx +2 -0
- package/src/SmoothClipView.ios.tsx +36 -0
- package/src/SmoothClipView.tsx +31 -27
- package/src/SmoothClipView.web.tsx +26 -22
- package/src/SmoothClipViewNativeComponent.ts +14 -1
- package/src/driverState.ts +150 -0
- package/src/driverTypes.ts +91 -0
- package/src/drivers.android.ts +6 -0
- package/src/drivers.ios.ts +665 -0
- package/src/drivers.ts +416 -0
- package/src/geometry.ts +39 -0
- package/src/index.ts +19 -1
- package/src/index.web.ts +19 -1
- package/src/nativeCompletion.ts +37 -0
- package/src/reactRequests.ts +64 -0
- package/src/smoothClipNative.android.ts +20 -0
- package/src/smoothClipNative.ts +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmoothClipViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/SmoothClipViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC;IAClC,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC;IAClC,gBAAgB,EAAE,YAAY,CAAC,MAAM,CAAC;IACtC,iBAAiB,EAAE,YAAY,CAAC,MAAM,CAAC;IACvC,iBAAiB,EAAE,YAAY,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"SmoothClipViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/SmoothClipViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC;IAC9B,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC;IAClC,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC;IAClC,gBAAgB,EAAE,YAAY,CAAC,MAAM,CAAC;IACtC,iBAAiB,EAAE,YAAY,CAAC,MAAM,CAAC;IACvC,iBAAiB,EAAE,YAAY,CAAC,MAAM,CAAC;IACvC,wBAAwB,EAAE,YAAY,CAAC,MAAM,CAAC;IAC9C,wBAAwB,EAAE,YAAY,CAAC,MAAM,CAAC;CAC/C;AAED,UAAU,cAAc;IACtB,eAAe,EAAE,CACf,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,EACrD,CAAC,EAAE,YAAY,CAAC,MAAM,EACtB,CAAC,EAAE,YAAY,CAAC,MAAM,EACtB,KAAK,EAAE,YAAY,CAAC,MAAM,EAC1B,MAAM,EAAE,YAAY,CAAC,MAAM,EAC3B,MAAM,EAAE,YAAY,CAAC,MAAM,KACxB,IAAI,CAAC;IACV,mBAAmB,EAAE,CACnB,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,EACrD,CAAC,EAAE,YAAY,CAAC,MAAM,EACtB,CAAC,EAAE,YAAY,CAAC,MAAM,EACtB,KAAK,EAAE,YAAY,CAAC,MAAM,EAC1B,MAAM,EAAE,YAAY,CAAC,MAAM,EAC3B,MAAM,EAAE,YAAY,CAAC,MAAM,EAC3B,iBAAiB,EAAE,YAAY,CAAC,MAAM,EACtC,iBAAiB,EAAE,YAAY,CAAC,MAAM,KACnC,IAAI,CAAC;CACX;AAED,eAAO,MAAM,QAAQ,EAAE,cAErB,CAAC;wBAIE,aAAa,CAAC,WAAW,CAAC;AAF/B,wBAEgC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import type { ClipAnimationResult, SmoothClipDriver } from './driverTypes.js';
|
|
3
|
+
import type { SmoothClipPresentation } from './geometry.js';
|
|
4
|
+
export type DriverState = {
|
|
5
|
+
driverId: number;
|
|
6
|
+
initialPresentation: SmoothClipPresentation;
|
|
7
|
+
source: SharedValue<SmoothClipPresentation>;
|
|
8
|
+
activeAnimationId?: SharedValue<number>;
|
|
9
|
+
ownership?: SharedValue<number>;
|
|
10
|
+
onAnimationComplete: {
|
|
11
|
+
current: ((result: ClipAnimationResult) => void) | undefined;
|
|
12
|
+
};
|
|
13
|
+
mountedViews: Set<object>;
|
|
14
|
+
animationParticipants: Map<number, Set<object>>;
|
|
15
|
+
failedAnimations: Set<number>;
|
|
16
|
+
completionDeferrals: number;
|
|
17
|
+
deferredCompletions: ClipAnimationResult[];
|
|
18
|
+
};
|
|
19
|
+
export declare function allocateDriverId(): number;
|
|
20
|
+
export declare function setDriverState(driver: SmoothClipDriver, state: DriverState): void;
|
|
21
|
+
export declare function attachDriverState(state: DriverState): void;
|
|
22
|
+
export declare function detachDriverState(state: DriverState): void;
|
|
23
|
+
export declare function createDriverState(driverId: number, initialPresentation: SmoothClipPresentation, source: SharedValue<SmoothClipPresentation>, onAnimationComplete: DriverState['onAnimationComplete'], activeAnimationId?: SharedValue<number>, ownership?: SharedValue<number>): DriverState;
|
|
24
|
+
export declare function registerDriverView(driver: SmoothClipDriver): () => void;
|
|
25
|
+
export declare function snapshotDriverViews(driverId: number, animationId: number): void;
|
|
26
|
+
export declare function finishDriverAnimation(driverId: number, animationId: number, finished: boolean): boolean;
|
|
27
|
+
export declare function deliverDriverCompletion(driverId: number, animationId: number, finished: boolean): void;
|
|
28
|
+
export declare function deferDriverCompletions(driverId: number): void;
|
|
29
|
+
export declare function releaseDriverCompletions(driverId: number): void;
|
|
30
|
+
export declare function getDriverState(driver: SmoothClipDriver): DriverState;
|
|
31
|
+
//# sourceMappingURL=driverState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driverState.d.ts","sourceRoot":"","sources":["../../../src/driverState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,kBAAe,CAAC;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAY,CAAC;AAEzD,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,sBAAsB,CAAC;IAC5C,MAAM,EAAE,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAC5C,iBAAiB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,mBAAmB,EAAE;QACnB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,mBAAmB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AAE,OAAO,GAChB,IAAI,CASN;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAG7D;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAS/D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW,CAQpE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import type { SmoothClipPresentation } from './geometry.js';
|
|
3
|
+
export type ClipReduceMotion = 'system' | 'always' | 'never';
|
|
4
|
+
export type TimingClipAnimation = Readonly<{
|
|
5
|
+
type: 'timing';
|
|
6
|
+
duration: number;
|
|
7
|
+
controlPoints: readonly [number, number, number, number];
|
|
8
|
+
}>;
|
|
9
|
+
export type SpringClipAnimation = Readonly<{
|
|
10
|
+
type: 'spring';
|
|
11
|
+
mass?: number;
|
|
12
|
+
stiffness?: number;
|
|
13
|
+
damping?: number;
|
|
14
|
+
initialVelocity?: number | 'inherit';
|
|
15
|
+
}>;
|
|
16
|
+
export type KeyframedClipAnimation = Readonly<{
|
|
17
|
+
type: 'keyframes';
|
|
18
|
+
duration: number;
|
|
19
|
+
frames: readonly Readonly<{
|
|
20
|
+
offset: number;
|
|
21
|
+
presentation: SmoothClipPresentation;
|
|
22
|
+
}>[];
|
|
23
|
+
}>;
|
|
24
|
+
export type SmoothClipAnimation = TimingClipAnimation | SpringClipAnimation | KeyframedClipAnimation;
|
|
25
|
+
export type ClipAnimationResult = Readonly<{
|
|
26
|
+
animationId: number;
|
|
27
|
+
finished: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
export type SmoothClipDriverOptions = Readonly<{
|
|
30
|
+
reduceMotion?: ClipReduceMotion;
|
|
31
|
+
onAnimationComplete?: (result: ClipAnimationResult) => void;
|
|
32
|
+
}>;
|
|
33
|
+
export type SmoothClipUIControls = Readonly<{
|
|
34
|
+
beginInteraction(): SmoothClipPresentation;
|
|
35
|
+
set(presentation: SmoothClipPresentation): void;
|
|
36
|
+
/**
|
|
37
|
+
* Per-frame hot path: writes geometry straight to native without touching
|
|
38
|
+
* `driver.presentation`. Skips SharedValue bookkeeping (dirty marking, RN
|
|
39
|
+
* mirror sync, listener dispatch) for high-frequency streams such as
|
|
40
|
+
* gestures. `driver.presentation.value` is stale after hot writes by design;
|
|
41
|
+
* `beginInteraction()` remains the source of truth for visible geometry.
|
|
42
|
+
* Do not interleave with `presentation.value` writes on the same driver —
|
|
43
|
+
* the listener's duplicate suppression may skip a later equal value.
|
|
44
|
+
*/
|
|
45
|
+
setScalars(x: number, y: number, width: number, height: number, radius: number, contentTranslateX: number, contentTranslateY: number): void;
|
|
46
|
+
animateTo(presentation: SmoothClipPresentation, animation: SmoothClipAnimation): number;
|
|
47
|
+
cancel(animationId?: number, behavior?: 'current' | 'target'): SmoothClipPresentation;
|
|
48
|
+
}>;
|
|
49
|
+
export type SmoothClipReactControls = Readonly<{
|
|
50
|
+
beginInteraction(): Promise<SmoothClipPresentation>;
|
|
51
|
+
set(presentation: SmoothClipPresentation): Promise<void>;
|
|
52
|
+
animateTo(presentation: SmoothClipPresentation, animation: SmoothClipAnimation): Promise<number>;
|
|
53
|
+
cancel(animationId?: number, behavior?: 'current' | 'target'): Promise<SmoothClipPresentation>;
|
|
54
|
+
}>;
|
|
55
|
+
export type SmoothClipDriver = Readonly<{
|
|
56
|
+
kind: 'hybrid';
|
|
57
|
+
presentation: SharedValue<SmoothClipPresentation>;
|
|
58
|
+
ui: SmoothClipUIControls;
|
|
59
|
+
react: SmoothClipReactControls;
|
|
60
|
+
}>;
|
|
61
|
+
//# sourceMappingURL=driverTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driverTypes.d.ts","sourceRoot":"","sources":["../../../src/driverTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,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oot":"","sources":["../../../src/drivers.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAe,CAAC;AACpD,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAe,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KeyframedClipAnimation, SmoothClipDriver, SmoothClipDriverOptions, SpringClipAnimation, TimingClipAnimation } from './driverTypes.js';
|
|
2
|
+
import { type ClipGeometry, type SmoothClipPresentation } from './geometry.js';
|
|
3
|
+
export declare function useSmoothClipDriver(initialValue: ClipGeometry | SmoothClipPresentation, options?: SmoothClipDriverOptions): SmoothClipDriver;
|
|
4
|
+
export type { KeyframedClipAnimation, SpringClipAnimation, TimingClipAnimation, };
|
|
5
|
+
//# sourceMappingURL=drivers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drivers.d.ts","sourceRoot":"","sources":["../../../src/drivers.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEV,sBAAsB,EAEtB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,kBAAe,CAAC;AAYvB,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC5B,MAAM,eAAY,CAAC;AAuFpB,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,GAAG,sBAAsB,EACnD,OAAO,GAAE,uBAA4B,GACpC,gBAAgB,CA0RlB;AAED,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KeyframedClipAnimation, SmoothClipDriver, SmoothClipDriverOptions, SpringClipAnimation, TimingClipAnimation } from './driverTypes.js';
|
|
2
|
+
import { type ClipGeometry, type SmoothClipPresentation } from './geometry.js';
|
|
3
|
+
export declare function useSmoothClipDriver(initialValue: ClipGeometry | SmoothClipPresentation, options?: SmoothClipDriverOptions): SmoothClipDriver;
|
|
4
|
+
export type { KeyframedClipAnimation, SpringClipAnimation, TimingClipAnimation, };
|
|
5
|
+
//# sourceMappingURL=drivers.ios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drivers.ios.d.ts","sourceRoot":"","sources":["../../../src/drivers.ios.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,sBAAsB,EAEtB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,kBAAe,CAAC;AAavB,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC5B,MAAM,eAAY,CAAC;AAyIpB,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,GAAG,sBAAsB,EACnD,OAAO,GAAE,uBAA4B,GACpC,gBAAgB,CAuelB;AAED,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,CAAC"}
|
|
@@ -9,8 +9,16 @@ export type ClipBounds = Readonly<{
|
|
|
9
9
|
width: number;
|
|
10
10
|
height: number;
|
|
11
11
|
}>;
|
|
12
|
+
export type SmoothClipPresentation = Readonly<{
|
|
13
|
+
clip: ClipGeometry;
|
|
14
|
+
contentTranslateX: number;
|
|
15
|
+
contentTranslateY: number;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function createClipPresentation(clip: ClipGeometry, contentTranslateX?: number, contentTranslateY?: number): SmoothClipPresentation;
|
|
12
18
|
export declare function isFiniteClipGeometry(geometry: ClipGeometry): boolean;
|
|
13
19
|
export declare function clipGeometryEquals(first: ClipGeometry | null, second: ClipGeometry): boolean;
|
|
20
|
+
export declare function isFiniteClipPresentation(presentation: SmoothClipPresentation): boolean;
|
|
21
|
+
export declare function clipPresentationEquals(first: SmoothClipPresentation | null, second: SmoothClipPresentation): boolean;
|
|
14
22
|
/**
|
|
15
23
|
* Mirrors the native geometry contract for tests and non-native fallbacks.
|
|
16
24
|
* Native remains authoritative because its bounds are the actual rendered size.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../src/geometry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CASpE;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,IAAI,EAC1B,MAAM,EAAE,YAAY,GACnB,OAAO,CAUT;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,GACjB,YAAY,GAAG,IAAI,CAoCrB"}
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../src/geometry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,IAAI,EAAE,YAAY,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC,CAAC;AAEH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,YAAY,EAClB,iBAAiB,SAAI,EACrB,iBAAiB,SAAI,GACpB,sBAAsB,CAGxB;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CASpE;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,IAAI,EAC1B,MAAM,EAAE,YAAY,GACnB,OAAO,CAUT;AAED,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,sBAAsB,GACnC,OAAO,CAOT;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,sBAAsB,GAAG,IAAI,EACpC,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAQT;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,GACjB,YAAY,GAAG,IAAI,CAoCrB"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { SmoothClipView } from './SmoothClipView';
|
|
2
2
|
export type { SmoothClipViewProps } from './SmoothClipView';
|
|
3
|
+
export { useSmoothClipDriver } from './drivers';
|
|
4
|
+
export type { ClipAnimationResult, ClipReduceMotion, KeyframedClipAnimation, SmoothClipDriver, SmoothClipDriverOptions, SmoothClipReactControls, SmoothClipUIControls, SmoothClipAnimation, SpringClipAnimation, TimingClipAnimation, } from './driverTypes.js';
|
|
3
5
|
export { normalizeClipGeometry } from './geometry.js';
|
|
4
|
-
export
|
|
6
|
+
export { createClipPresentation } from './geometry.js';
|
|
7
|
+
export type { ClipBounds, ClipGeometry, SmoothClipPresentation, } from './geometry.js';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,qBAAqB,EAAE,MAAM,eAAY,CAAC;AACnD,
|
|
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,5 +1,8 @@
|
|
|
1
1
|
export { SmoothClipView } from './SmoothClipView.web.js';
|
|
2
2
|
export type { SmoothClipViewProps } from './SmoothClipView.web.js';
|
|
3
|
+
export { useSmoothClipDriver } from './drivers';
|
|
4
|
+
export type { ClipAnimationResult, ClipReduceMotion, KeyframedClipAnimation, SmoothClipDriver, SmoothClipDriverOptions, SmoothClipReactControls, SmoothClipUIControls, SmoothClipAnimation, SpringClipAnimation, TimingClipAnimation, } from './driverTypes.js';
|
|
3
5
|
export { normalizeClipGeometry } from './geometry.js';
|
|
4
|
-
export
|
|
6
|
+
export { createClipPresentation } from './geometry.js';
|
|
7
|
+
export type { ClipBounds, ClipGeometry, SmoothClipPresentation, } from './geometry.js';
|
|
5
8
|
//# sourceMappingURL=index.web.d.ts.map
|
|
@@ -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,qBAAqB,EAAE,MAAM,eAAY,CAAC;AACnD,
|
|
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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function completeNativeAnimation(driverId: number, animationId: number, finished: boolean): void;
|
|
2
|
+
export declare function synchronizeNativeCompletion(activeAnimationId: {
|
|
3
|
+
value: number;
|
|
4
|
+
}, ownership: {
|
|
5
|
+
value: number;
|
|
6
|
+
}, animationId: number, _finished: boolean): void;
|
|
7
|
+
//# sourceMappingURL=nativeCompletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeCompletion.d.ts","sourceRoot":"","sources":["../../../src/nativeCompletion.ts"],"names":[],"mappings":"AAGA,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,GAChB,IAAI,CAEN;AAED,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EACpC,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,OAAO,GACjB,IAAI,CAoBN"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function createReactRequest<T>(driverId: number, deferCompletions?: boolean): {
|
|
2
|
+
requestId: number;
|
|
3
|
+
promise: Promise<T>;
|
|
4
|
+
};
|
|
5
|
+
export declare function resolveReactRequest(driverId: number, requestId: number, value: unknown, releaseCompletions?: boolean): void;
|
|
6
|
+
export declare function rejectDriverRequests(driverId: number): void;
|
|
7
|
+
//# sourceMappingURL=reactRequests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactRequests.d.ts","sourceRoot":"","sources":["../../../src/reactRequests.ts"],"names":[],"mappings":"AAcA,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,UAAQ,GACvB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CAAE,CAkB5C;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,kBAAkB,UAAQ,GACzB,IAAI,CAUN;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAS3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smoothClipNative.android.d.ts","sourceRoot":"","sources":["../../../src/smoothClipNative.android.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA0B,CAAC;AASrD,QAAA,MAAM,QAAQ,kBACK,CAAC;AAQpB,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smoothClipNative.d.ts","sourceRoot":"","sources":["../../../src/smoothClipNative.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,6BAA0B,CAAC;AAI9D,eAAe,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-smooth-clip-view",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"lib",
|
|
21
21
|
"android",
|
|
22
22
|
"ios",
|
|
23
|
+
"cpp",
|
|
23
24
|
"SmoothClipView.podspec",
|
|
24
25
|
"README.md",
|
|
25
26
|
"LICENSE",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"!**/.*"
|
|
34
35
|
],
|
|
35
36
|
"scripts": {
|
|
36
|
-
"example": "
|
|
37
|
+
"example": "npm run --workspace react-native-smooth-clip-view-example",
|
|
37
38
|
"clean": "del-cli lib",
|
|
38
39
|
"prepare": "bob build",
|
|
39
40
|
"typecheck": "tsc",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"@commitlint/config-conventional": "^21.0.2",
|
|
73
74
|
"@eslint/compat": "^2.1.0",
|
|
74
75
|
"@eslint/eslintrc": "^3.3.5",
|
|
75
|
-
"@eslint/js": "^
|
|
76
|
+
"@eslint/js": "^9.39.4",
|
|
76
77
|
"@jest/globals": "^29.7.0",
|
|
77
78
|
"@react-native/babel-preset": "0.86.0",
|
|
78
79
|
"@react-native/eslint-config": "0.86.0",
|
|
@@ -101,13 +102,14 @@
|
|
|
101
102
|
},
|
|
102
103
|
"peerDependencies": {
|
|
103
104
|
"react": "*",
|
|
104
|
-
"react-native": ">=0.
|
|
105
|
-
"react-native-reanimated": ">=4.
|
|
105
|
+
"react-native": ">=0.86.0",
|
|
106
|
+
"react-native-reanimated": ">=4.5.0",
|
|
107
|
+
"react-native-worklets": ">=0.10.0"
|
|
106
108
|
},
|
|
107
109
|
"workspaces": [
|
|
108
110
|
"example"
|
|
109
111
|
],
|
|
110
|
-
"packageManager": "
|
|
112
|
+
"packageManager": "npm@11.8.0",
|
|
111
113
|
"react-native-builder-bob": {
|
|
112
114
|
"source": "src",
|
|
113
115
|
"output": "lib",
|
|
@@ -128,7 +130,7 @@
|
|
|
128
130
|
},
|
|
129
131
|
"codegenConfig": {
|
|
130
132
|
"name": "SmoothClipViewSpec",
|
|
131
|
-
"type": "
|
|
133
|
+
"type": "all",
|
|
132
134
|
"jsSrcsDir": "src",
|
|
133
135
|
"android": {
|
|
134
136
|
"javaPackageName": "com.smoothclipview"
|
|
@@ -138,6 +140,9 @@
|
|
|
138
140
|
"SmoothClipView": {
|
|
139
141
|
"className": "SmoothClipView"
|
|
140
142
|
}
|
|
143
|
+
},
|
|
144
|
+
"modulesProvider": {
|
|
145
|
+
"NativeSmoothClipModule": "SmoothClipModuleProvider"
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
},
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { CodegenTypes, TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
readonly onClipAnimationComplete: CodegenTypes.EventEmitter<
|
|
6
|
+
Readonly<{
|
|
7
|
+
driverId: CodegenTypes.Double;
|
|
8
|
+
animationId: CodegenTypes.Int32;
|
|
9
|
+
finished: boolean;
|
|
10
|
+
}>
|
|
11
|
+
>;
|
|
12
|
+
setClipPresentation(
|
|
13
|
+
driverId: CodegenTypes.Double,
|
|
14
|
+
x: CodegenTypes.Double,
|
|
15
|
+
y: CodegenTypes.Double,
|
|
16
|
+
width: CodegenTypes.Double,
|
|
17
|
+
height: CodegenTypes.Double,
|
|
18
|
+
radius: CodegenTypes.Double,
|
|
19
|
+
contentTranslateX: CodegenTypes.Double,
|
|
20
|
+
contentTranslateY: CodegenTypes.Double,
|
|
21
|
+
takeOwnership: boolean
|
|
22
|
+
): void;
|
|
23
|
+
beginInteraction(
|
|
24
|
+
driverId: CodegenTypes.Double
|
|
25
|
+
): ReadonlyArray<CodegenTypes.Double>;
|
|
26
|
+
animateTiming(
|
|
27
|
+
driverId: CodegenTypes.Double,
|
|
28
|
+
hasInteractiveStart: boolean,
|
|
29
|
+
startX: CodegenTypes.Double,
|
|
30
|
+
startY: CodegenTypes.Double,
|
|
31
|
+
startWidth: CodegenTypes.Double,
|
|
32
|
+
startHeight: CodegenTypes.Double,
|
|
33
|
+
startRadius: CodegenTypes.Double,
|
|
34
|
+
startContentTranslateX: CodegenTypes.Double,
|
|
35
|
+
startContentTranslateY: CodegenTypes.Double,
|
|
36
|
+
x: CodegenTypes.Double,
|
|
37
|
+
y: CodegenTypes.Double,
|
|
38
|
+
width: CodegenTypes.Double,
|
|
39
|
+
height: CodegenTypes.Double,
|
|
40
|
+
radius: CodegenTypes.Double,
|
|
41
|
+
contentTranslateX: CodegenTypes.Double,
|
|
42
|
+
contentTranslateY: CodegenTypes.Double,
|
|
43
|
+
durationMs: CodegenTypes.Double,
|
|
44
|
+
controlPoint1X: CodegenTypes.Double,
|
|
45
|
+
controlPoint1Y: CodegenTypes.Double,
|
|
46
|
+
controlPoint2X: CodegenTypes.Double,
|
|
47
|
+
controlPoint2Y: CodegenTypes.Double,
|
|
48
|
+
reduceMotion: CodegenTypes.Int32
|
|
49
|
+
): CodegenTypes.Int32;
|
|
50
|
+
animateSpring(
|
|
51
|
+
driverId: CodegenTypes.Double,
|
|
52
|
+
hasInteractiveStart: boolean,
|
|
53
|
+
startX: CodegenTypes.Double,
|
|
54
|
+
startY: CodegenTypes.Double,
|
|
55
|
+
startWidth: CodegenTypes.Double,
|
|
56
|
+
startHeight: CodegenTypes.Double,
|
|
57
|
+
startRadius: CodegenTypes.Double,
|
|
58
|
+
startContentTranslateX: CodegenTypes.Double,
|
|
59
|
+
startContentTranslateY: CodegenTypes.Double,
|
|
60
|
+
x: CodegenTypes.Double,
|
|
61
|
+
y: CodegenTypes.Double,
|
|
62
|
+
width: CodegenTypes.Double,
|
|
63
|
+
height: CodegenTypes.Double,
|
|
64
|
+
radius: CodegenTypes.Double,
|
|
65
|
+
contentTranslateX: CodegenTypes.Double,
|
|
66
|
+
contentTranslateY: CodegenTypes.Double,
|
|
67
|
+
mass: CodegenTypes.Double,
|
|
68
|
+
stiffness: CodegenTypes.Double,
|
|
69
|
+
damping: CodegenTypes.Double,
|
|
70
|
+
initialVelocity: CodegenTypes.Double,
|
|
71
|
+
inheritVelocity: boolean,
|
|
72
|
+
reduceMotion: CodegenTypes.Int32
|
|
73
|
+
): CodegenTypes.Int32;
|
|
74
|
+
animateKeyframes(
|
|
75
|
+
driverId: CodegenTypes.Double,
|
|
76
|
+
hasInteractiveStart: boolean,
|
|
77
|
+
startX: CodegenTypes.Double,
|
|
78
|
+
startY: CodegenTypes.Double,
|
|
79
|
+
startWidth: CodegenTypes.Double,
|
|
80
|
+
startHeight: CodegenTypes.Double,
|
|
81
|
+
startRadius: CodegenTypes.Double,
|
|
82
|
+
startContentTranslateX: CodegenTypes.Double,
|
|
83
|
+
startContentTranslateY: CodegenTypes.Double,
|
|
84
|
+
x: CodegenTypes.Double,
|
|
85
|
+
y: CodegenTypes.Double,
|
|
86
|
+
width: CodegenTypes.Double,
|
|
87
|
+
height: CodegenTypes.Double,
|
|
88
|
+
radius: CodegenTypes.Double,
|
|
89
|
+
contentTranslateX: CodegenTypes.Double,
|
|
90
|
+
contentTranslateY: CodegenTypes.Double,
|
|
91
|
+
durationMs: CodegenTypes.Double,
|
|
92
|
+
frames: ReadonlyArray<CodegenTypes.Double>,
|
|
93
|
+
reduceMotion: CodegenTypes.Int32
|
|
94
|
+
): CodegenTypes.Int32;
|
|
95
|
+
rejectAnimation(driverId: CodegenTypes.Double): CodegenTypes.Int32;
|
|
96
|
+
cancelAnimation(
|
|
97
|
+
driverId: CodegenTypes.Double,
|
|
98
|
+
animationId: CodegenTypes.Int32,
|
|
99
|
+
behavior: CodegenTypes.Int32
|
|
100
|
+
): ReadonlyArray<CodegenTypes.Double>;
|
|
101
|
+
destroyDriver(driverId: CodegenTypes.Double): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('NativeSmoothClipModule');
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type ViewProps } from 'react-native';
|
|
3
|
+
import type { SmoothClipDriver } from './driverTypes';
|
|
4
|
+
import { getDriverState } from './driverState';
|
|
5
|
+
import NativeSmoothClipView, {
|
|
6
|
+
type NativeProps,
|
|
7
|
+
} from './SmoothClipViewNativeComponent';
|
|
8
|
+
|
|
9
|
+
export type SmoothClipViewProps = ViewProps & {
|
|
10
|
+
driver: SmoothClipDriver;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function SmoothClipView({
|
|
15
|
+
driver,
|
|
16
|
+
children,
|
|
17
|
+
...viewProps
|
|
18
|
+
}: SmoothClipViewProps) {
|
|
19
|
+
const { driverId, initialPresentation } = getDriverState(driver);
|
|
20
|
+
const { clip } = initialPresentation;
|
|
21
|
+
const nativeProps: NativeProps = {
|
|
22
|
+
...viewProps,
|
|
23
|
+
driverId,
|
|
24
|
+
initialClipX: clip.x,
|
|
25
|
+
initialClipY: clip.y,
|
|
26
|
+
initialClipWidth: clip.width,
|
|
27
|
+
initialClipHeight: clip.height,
|
|
28
|
+
initialClipRadius: clip.radius,
|
|
29
|
+
initialContentTranslateX: initialPresentation.contentTranslateX,
|
|
30
|
+
initialContentTranslateY: initialPresentation.contentTranslateY,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<NativeSmoothClipView {...nativeProps}>{children}</NativeSmoothClipView>
|
|
35
|
+
);
|
|
36
|
+
}
|
package/src/SmoothClipView.tsx
CHANGED
|
@@ -1,67 +1,71 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type ReactNode, useEffect } from 'react';
|
|
3
3
|
import { type ViewProps } from 'react-native';
|
|
4
4
|
import Animated, {
|
|
5
5
|
dispatchCommand,
|
|
6
6
|
useAnimatedReaction,
|
|
7
7
|
useAnimatedRef,
|
|
8
|
-
type SharedValue,
|
|
9
8
|
} from 'react-native-reanimated';
|
|
9
|
+
import type { SmoothClipDriver } from './driverTypes';
|
|
10
|
+
import { getDriverState, registerDriverView } from './driverState';
|
|
11
|
+
import { clipPresentationEquals, isFiniteClipPresentation } from './geometry';
|
|
10
12
|
import NativeSmoothClipView, {
|
|
11
13
|
type NativeProps,
|
|
12
14
|
} from './SmoothClipViewNativeComponent';
|
|
13
|
-
import {
|
|
14
|
-
clipGeometryEquals,
|
|
15
|
-
isFiniteClipGeometry,
|
|
16
|
-
type ClipGeometry,
|
|
17
|
-
} from './geometry';
|
|
18
15
|
|
|
19
16
|
const AnimatedNativeSmoothClipView =
|
|
20
17
|
Animated.createAnimatedComponent(NativeSmoothClipView);
|
|
21
18
|
|
|
22
19
|
export type SmoothClipViewProps = ViewProps & {
|
|
23
|
-
|
|
24
|
-
animatedClip: SharedValue<ClipGeometry>;
|
|
20
|
+
driver: SmoothClipDriver;
|
|
25
21
|
children?: ReactNode;
|
|
26
22
|
};
|
|
27
23
|
|
|
24
|
+
/** Android fallback. iOS resolves SmoothClipView.ios.tsx instead. */
|
|
28
25
|
export function SmoothClipView({
|
|
29
|
-
|
|
30
|
-
animatedClip,
|
|
26
|
+
driver,
|
|
31
27
|
children,
|
|
32
28
|
...viewProps
|
|
33
29
|
}: SmoothClipViewProps) {
|
|
30
|
+
const { driverId, initialPresentation, source } = getDriverState(driver);
|
|
31
|
+
const { clip } = initialPresentation;
|
|
32
|
+
useEffect(() => registerDriverView(driver), [driver]);
|
|
34
33
|
const nativeRef =
|
|
35
34
|
useAnimatedRef<React.ComponentRef<typeof NativeSmoothClipView>>();
|
|
36
35
|
|
|
37
36
|
useAnimatedReaction(
|
|
38
|
-
() =>
|
|
39
|
-
(
|
|
37
|
+
() => source.value,
|
|
38
|
+
(presentation, previousPresentation) => {
|
|
40
39
|
if (
|
|
41
|
-
!
|
|
42
|
-
|
|
40
|
+
!isFiniteClipPresentation(presentation) ||
|
|
41
|
+
clipPresentationEquals(previousPresentation, presentation)
|
|
43
42
|
) {
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
dispatchCommand(nativeRef, '
|
|
48
|
-
clip.x,
|
|
49
|
-
clip.y,
|
|
50
|
-
clip.width,
|
|
51
|
-
clip.height,
|
|
52
|
-
clip.radius,
|
|
46
|
+
dispatchCommand(nativeRef, 'setClipPresentation', [
|
|
47
|
+
presentation.clip.x,
|
|
48
|
+
presentation.clip.y,
|
|
49
|
+
presentation.clip.width,
|
|
50
|
+
presentation.clip.height,
|
|
51
|
+
presentation.clip.radius,
|
|
52
|
+
presentation.contentTranslateX,
|
|
53
|
+
presentation.contentTranslateY,
|
|
53
54
|
]);
|
|
54
55
|
},
|
|
55
|
-
[nativeRef,
|
|
56
|
+
[nativeRef, source]
|
|
56
57
|
);
|
|
57
58
|
|
|
58
59
|
const nativeProps: NativeProps = {
|
|
59
60
|
...viewProps,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
driverId,
|
|
62
|
+
initialClipX: clip.x,
|
|
63
|
+
initialClipY: clip.y,
|
|
64
|
+
initialClipWidth: clip.width,
|
|
65
|
+
initialClipHeight: clip.height,
|
|
66
|
+
initialClipRadius: clip.radius,
|
|
67
|
+
initialContentTranslateX: initialPresentation.contentTranslateX,
|
|
68
|
+
initialContentTranslateY: initialPresentation.contentTranslateY,
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
return (
|