@onekeyfe/react-native-native-overlay 6.7.0-alpha.475 → 6.8.0-3
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 +119 -21
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayEntryRootView.kt +60 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayView.kt +12 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayViewManager.kt +8 -0
- package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlayMotionTest.kt +42 -0
- package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlaySheetInsetTest.kt +78 -0
- package/docs/SPEC.md +189 -24
- package/ios/NativeOverlayContainerView.swift +6 -0
- package/ios/NativeOverlayWindowManager.swift +244 -7
- package/lib/module/NativeOverlayNativeComponent.ts +13 -0
- package/lib/module/OverlayView.js +7 -1
- package/lib/module/OverlayView.js.map +1 -1
- package/lib/module/animation/anchoredOrigin.js +26 -0
- package/lib/module/animation/anchoredOrigin.js.map +1 -0
- package/lib/module/animation/resolveAnimation.js +26 -4
- package/lib/module/animation/resolveAnimation.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/web/animateTransition.js +38 -12
- package/lib/module/web/animateTransition.js.map +1 -1
- package/lib/typescript/src/NativeOverlayNativeComponent.d.ts +13 -0
- package/lib/typescript/src/NativeOverlayNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/OverlayView.d.ts.map +1 -1
- package/lib/typescript/src/animation/anchoredOrigin.d.ts +7 -0
- package/lib/typescript/src/animation/anchoredOrigin.d.ts.map +1 -0
- package/lib/typescript/src/animation/resolveAnimation.d.ts +9 -3
- package/lib/typescript/src/animation/resolveAnimation.d.ts.map +1 -1
- package/lib/typescript/src/animation/types.d.ts +5 -1
- package/lib/typescript/src/animation/types.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/web/animateTransition.d.ts +12 -0
- package/lib/typescript/src/web/animateTransition.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeOverlayNativeComponent.ts +13 -0
- package/src/OverlayView.tsx +7 -0
- package/src/animation/anchoredOrigin.ts +35 -0
- package/src/animation/resolveAnimation.ts +28 -7
- package/src/animation/types.ts +5 -1
- package/src/index.ts +1 -0
- package/src/web/animateTransition.ts +54 -14
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAnchoredTransformOrigin } from '../animation/anchoredOrigin';
|
|
1
2
|
import { springToCssLinear } from '../animation/spring';
|
|
2
3
|
|
|
3
4
|
import type { IResolvedOverlayTransition } from '../animation/resolveAnimation';
|
|
@@ -91,6 +92,45 @@ const VISIBLE_KEYFRAME: Keyframe = {
|
|
|
91
92
|
transform: 'translate3d(0, 0, 0) scale(1)',
|
|
92
93
|
};
|
|
93
94
|
|
|
95
|
+
export interface ITransitionKeyframeInput {
|
|
96
|
+
transition: IResolvedOverlayTransition;
|
|
97
|
+
extent: IContentExtent;
|
|
98
|
+
direction: 'in' | 'out';
|
|
99
|
+
/** Rendered frames of an interrupted run; the new run starts from them. */
|
|
100
|
+
sampled?: Keyframe;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Keyframes for one enter/exit run. Pure so the interruption rules can be
|
|
105
|
+
* tested without a DOM.
|
|
106
|
+
*/
|
|
107
|
+
export function buildTransitionKeyframes({
|
|
108
|
+
transition,
|
|
109
|
+
extent,
|
|
110
|
+
direction,
|
|
111
|
+
sampled,
|
|
112
|
+
}: ITransitionKeyframeInput): [Keyframe, Keyframe] {
|
|
113
|
+
const hidden = hiddenKeyframe(transition, extent);
|
|
114
|
+
const visible: Keyframe = {};
|
|
115
|
+
Object.keys(hidden).forEach((key) => {
|
|
116
|
+
visible[key] = VISIBLE_KEYFRAME[key];
|
|
117
|
+
});
|
|
118
|
+
const initial = direction === 'in' ? hidden : visible;
|
|
119
|
+
const start: Keyframe = {};
|
|
120
|
+
Object.keys(initial).forEach((key) => {
|
|
121
|
+
start[key] = sampled?.[key] ?? initial[key];
|
|
122
|
+
});
|
|
123
|
+
const end: Keyframe = direction === 'in' ? visible : hidden;
|
|
124
|
+
// A fade-free exit does not animate opacity. Drop a partly transparent frame
|
|
125
|
+
// left by an interrupted fade-in so the card stays opaque while it scales out
|
|
126
|
+
// (OK-66647).
|
|
127
|
+
if (direction === 'out' && hidden.opacity === undefined) {
|
|
128
|
+
start.opacity = 1;
|
|
129
|
+
end.opacity = 1;
|
|
130
|
+
}
|
|
131
|
+
return [start, end];
|
|
132
|
+
}
|
|
133
|
+
|
|
94
134
|
/**
|
|
95
135
|
* Runs an enter (`direction: 'in'`) or exit transition on `element`. The
|
|
96
136
|
* slide distance and scale origin come from the children of `contentRoot`,
|
|
@@ -120,21 +160,21 @@ export function animateTransition(
|
|
|
120
160
|
anchoredContent instanceof HTMLElement ? anchoredContent : element;
|
|
121
161
|
const targetRect =
|
|
122
162
|
target === element ? undefined : target.getBoundingClientRect();
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
163
|
+
const anchorOrigin =
|
|
164
|
+
target === element
|
|
165
|
+
? undefined
|
|
166
|
+
: getAnchoredTransformOrigin(target.dataset.placement);
|
|
167
|
+
target.style.transformOrigin =
|
|
168
|
+
anchorOrigin ??
|
|
169
|
+
`${(extent.left + extent.right) / 2 - (targetRect?.left ?? 0)}px ${
|
|
170
|
+
(extent.top + extent.bottom) / 2 - (targetRect?.top ?? 0)
|
|
171
|
+
}px`;
|
|
172
|
+
const keyframes = buildTransitionKeyframes({
|
|
173
|
+
transition: effective,
|
|
174
|
+
extent,
|
|
175
|
+
direction,
|
|
176
|
+
sampled: interruptedFrames?.get(target),
|
|
136
177
|
});
|
|
137
|
-
const keyframes = [start, direction === 'in' ? visible : hidden];
|
|
138
178
|
return target.animate(keyframes, {
|
|
139
179
|
...toTiming(effective.motion),
|
|
140
180
|
fill: 'forwards',
|