@onekeyfe/react-native-native-overlay 6.7.0-31 → 6.7.0-32
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/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayView.kt +6 -0
- package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlayMotionTest.kt +42 -0
- package/docs/SPEC.md +40 -11
- package/ios/NativeOverlayContainerView.swift +6 -0
- package/lib/module/animation/resolveAnimation.js +26 -4
- package/lib/module/animation/resolveAnimation.js.map +1 -1
- package/lib/module/web/animateTransition.js +35 -11
- package/lib/module/web/animateTransition.js.map +1 -1
- 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/web/animateTransition.d.ts +12 -0
- package/lib/typescript/src/web/animateTransition.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/animation/resolveAnimation.ts +28 -7
- package/src/animation/types.ts +5 -1
- package/src/web/animateTransition.ts +44 -11
|
@@ -235,6 +235,12 @@ class NativeOverlayView(
|
|
|
235
235
|
notifyHostEntriesChanged()
|
|
236
236
|
val transition = config.exit.reduceMotionAdjusted(isReduceMotionEnabled())
|
|
237
237
|
if (transition.kind == "none") return finishDismiss("programmatic")
|
|
238
|
+
// A fade-free exit does not animate alpha. If the fade-in was interrupted,
|
|
239
|
+
// the card would otherwise stay partly transparent and show the content
|
|
240
|
+
// behind it for the whole scale-out (OK-66647).
|
|
241
|
+
if (!transition.hidesOpacity) {
|
|
242
|
+
target.animatedView.alpha = 1f
|
|
243
|
+
}
|
|
238
244
|
animate(target, hiddenState(target, transition), 0f, transition.motion) {
|
|
239
245
|
if (phase == Phase.EXITING) finishDismiss("programmatic")
|
|
240
246
|
}
|
|
@@ -114,6 +114,48 @@ class NativeOverlayMotionTest {
|
|
|
114
114
|
assertEquals(1, dismissals)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
@Test
|
|
118
|
+
fun fadeFreeExitSnapsAnInterruptedFadeInToFullOpacity() {
|
|
119
|
+
val activity = Robolectric.buildActivity(ComponentActivity::class.java).setup().visible().get()
|
|
120
|
+
val reactContext = BridgeReactContext(activity)
|
|
121
|
+
reactContext.onHostResume(activity)
|
|
122
|
+
val context = ThemedReactContext(reactContext, activity, "OverlayMotionTest", 1)
|
|
123
|
+
val quick = """{"type":"spring","spring":{"mass":0.1,"stiffness":100,"damping":20}}"""
|
|
124
|
+
val overlay = NativeOverlayView(context).apply {
|
|
125
|
+
presentation = "center"
|
|
126
|
+
animationConfig = """
|
|
127
|
+
{"enter":{"type":"scale","scale":0.85,"fade":true,"motion":$quick},
|
|
128
|
+
"exit":{"type":"scale","scale":0.96,"fade":false,"motion":$quick},
|
|
129
|
+
"backdrop":{"motion":$quick}}
|
|
130
|
+
""".trimIndent()
|
|
131
|
+
addReactChild(View(context))
|
|
132
|
+
}
|
|
133
|
+
activity.setContentView(overlay)
|
|
134
|
+
overlay.visible = true
|
|
135
|
+
overlay.commitConfiguration()
|
|
136
|
+
|
|
137
|
+
val entryField = NativeOverlayView::class.java.getDeclaredField("entry").apply { isAccessible = true }
|
|
138
|
+
val entry = entryField.get(overlay) as NativeOverlayEntryRootView
|
|
139
|
+
val animatorField = NativeOverlayView::class.java.getDeclaredField("contentAnimator").apply { isAccessible = true }
|
|
140
|
+
val enterAnimator = animatorField.get(overlay) as ValueAnimator
|
|
141
|
+
// Freeze a frame of the running fade-in: closing now starts the exit from a
|
|
142
|
+
// partly transparent surface.
|
|
143
|
+
enterAnimator.currentPlayTime = enterAnimator.duration / 3
|
|
144
|
+
val interruptedAlpha = entry.animatedView.alpha
|
|
145
|
+
assertTrue(interruptedAlpha > 0f && interruptedAlpha < 1f)
|
|
146
|
+
|
|
147
|
+
overlay.visible = false
|
|
148
|
+
overlay.commitConfiguration()
|
|
149
|
+
|
|
150
|
+
// A fade-free exit must not start from the interrupted alpha: the card stays
|
|
151
|
+
// fully opaque while it scales out so the content behind it cannot show through.
|
|
152
|
+
assertEquals(1f, entry.animatedView.alpha, 0.001f)
|
|
153
|
+
val exitAnimator = animatorField.get(overlay) as ValueAnimator
|
|
154
|
+
assertEquals(292L, exitAnimator.duration)
|
|
155
|
+
exitAnimator.currentPlayTime = exitAnimator.duration / 3
|
|
156
|
+
assertEquals(1f, entry.animatedView.alpha, 0.001f)
|
|
157
|
+
}
|
|
158
|
+
|
|
117
159
|
@Test
|
|
118
160
|
fun finishingExitMovesTransitioningContentBackToStagingView() {
|
|
119
161
|
val activity = Robolectric.buildActivity(ComponentActivity::class.java).setup().visible().get()
|
package/docs/SPEC.md
CHANGED
|
@@ -176,7 +176,10 @@ visible)`, `removePage(ownerKey)`.
|
|
|
176
176
|
|
|
177
177
|
- `animation.enter` and `animation.exit` are each
|
|
178
178
|
`{ type: none|fade|slide|scale, edge, distance, scale, offsetY, fade, origin: center|anchor, motion }`.
|
|
179
|
-
- `exit`
|
|
179
|
+
- `exit` resolution order: a caller-supplied `animation.exit`, otherwise a
|
|
180
|
+
mirror of a caller-supplied `animation.enter` (so custom enters keep their
|
|
181
|
+
old reverse exit), otherwise the presentation's own default exit (currently
|
|
182
|
+
only `center`, see below), otherwise the default `enter`.
|
|
180
183
|
- `motion` is a preset name or a concrete `{ type: 'spring', spring: { mass, stiffness, damping, overshootClamping } }`
|
|
181
184
|
or `{ type: 'timing', timing: { durationMs, easing: cubicBezier } }`.
|
|
182
185
|
- Presets are resolved per platform:
|
|
@@ -199,14 +202,34 @@ visible)`, `removePage(ownerKey)`.
|
|
|
199
202
|
it would slow web overlays down 4–9×.
|
|
200
203
|
- Presentation defaults (`DEFAULT_OVERLAY_ANIMATIONS`):
|
|
201
204
|
|
|
202
|
-
| Presentation | Enter
|
|
203
|
-
| ------------ |
|
|
204
|
-
| sheet | slide from bottom, `quick`
|
|
205
|
-
| center | scale 0.85 + fade, `quick`
|
|
206
|
-
| toast | slide from top + fade, `toastSlide` (native 300 ms quad in-out, web 400 ms ease) | none |
|
|
207
|
-
| fullscreen | fade, `quick`
|
|
208
|
-
| anchored | scale 0.95 + fade from the resolved anchor placement, `popoverQuick`
|
|
209
|
-
|
|
205
|
+
| Presentation | Enter | Exit | Backdrop |
|
|
206
|
+
| ------------ | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ------------- |
|
|
207
|
+
| sheet | slide from bottom, `quick` | same as enter | fade, `quick` |
|
|
208
|
+
| center | scale 0.85 + fade, `quick` | scale 0.96 without fade, `quick` | fade, `quick` |
|
|
209
|
+
| toast | slide from top + fade, `toastSlide` (native 300 ms quad in-out, web 400 ms ease) | same as enter | none |
|
|
210
|
+
| fullscreen | fade, `quick` | same as enter | none |
|
|
211
|
+
| anchored | scale 0.95 + fade from the resolved anchor placement, `popoverQuick` | same as enter | fade |
|
|
212
|
+
|
|
213
|
+
- **Centered card keeps its surface opaque on exit (Implemented; consumer Web
|
|
214
|
+
runtime evidence pending):** a centered Dialog is a solid card over the page
|
|
215
|
+
or over another overlay. Fading the card out made any opaque content behind
|
|
216
|
+
it — a text-heavy page, the account list inside the account selector —
|
|
217
|
+
readable through the card for the whole transition, which consumers reported
|
|
218
|
+
as a doubled render right after closing a dialog (OK-66647, desktop, 120 fps
|
|
219
|
+
recording: the card reached ~20–30 % opacity while the list rows behind
|
|
220
|
+
stayed opaque). The default exit therefore shrinks the card from scale 1 to
|
|
221
|
+
0.96 with `fade: false`; the host unmounts it when the exit completes.
|
|
222
|
+
`fade: false` is honoured by all three renderers (`hidesOpacity` on iOS and
|
|
223
|
+
Android, `hiddenKeyframe` on Web), and the backdrop still fades on the same
|
|
224
|
+
clock. A fade-free exit also starts from full opacity: when it interrupts a
|
|
225
|
+
still-running fade-in, the partly transparent surface is snapped back to
|
|
226
|
+
alpha 1 before the scale-out begins, so a rapid close cannot show the
|
|
227
|
+
content behind the card either. That interruption is covered by
|
|
228
|
+
`NativeOverlayMotionTest` on Android and by `buildTransitionKeyframes` on
|
|
229
|
+
Web; the iOS dismiss path lives in `NativeOverlayContainerView`, which the
|
|
230
|
+
iOS test app does not compile, so its snap is source-reviewed only. Reduce
|
|
231
|
+
Motion still degrades the exit to a fade on every platform, so this
|
|
232
|
+
protection does not apply there.
|
|
210
233
|
- **Android sheet transform ownership (Implemented; Android 16 consumer-shell runtime verified):**
|
|
211
234
|
the overlay's enter/exit transform belongs to the sheet's CoordinatorLayout
|
|
212
235
|
parent. Material's IME insets callback owns the child sheet's `translationY`,
|
|
@@ -669,7 +692,9 @@ Automated (P0):
|
|
|
669
692
|
reparenting in both directions, including the exit-completion staging path,
|
|
670
693
|
old-parent transition completion after the move, and reopen during exit.
|
|
671
694
|
It also covers Fabric removal of staged content and replacement of presented
|
|
672
|
-
content during a transition, including layout-listener cleanup
|
|
695
|
+
content during a transition, including layout-listener cleanup, and the
|
|
696
|
+
fade-free centered exit snapping an interrupted fade-in to full opacity
|
|
697
|
+
before the scale-out.
|
|
673
698
|
- `NativeOverlayPageHostLayoutTest` places the Android page host below an
|
|
674
699
|
actual `ReactViewGroup` and checks a sheet at 200, 600 and 320 px after
|
|
675
700
|
attachment. Height changes MUST relayout and bottom-pin the sheet without
|
|
@@ -698,7 +723,11 @@ Automated (P0):
|
|
|
698
723
|
- the spring response in all damping regimes, overshoot clamping and settle
|
|
699
724
|
time;
|
|
700
725
|
- Android `SpringForce` conversion and CSS `linear()` sampling;
|
|
701
|
-
- presentation defaults and per-platform preset resolution
|
|
726
|
+
- presentation defaults and per-platform preset resolution, including the
|
|
727
|
+
centered fade-free exit and a caller-supplied exit override;
|
|
728
|
+
- Web enter/exit keyframes: a fade-free exit keeps opacity 1 when it
|
|
729
|
+
interrupts a partial fade-in, a fading exit starts from the interrupted
|
|
730
|
+
opacity, and the interrupted enter transform is retargeted.
|
|
702
731
|
|
|
703
732
|
Runtime matrix, required per platform before migrating callers (P1–P3):
|
|
704
733
|
|
|
@@ -470,6 +470,12 @@ final class NativeOverlayEntryView: UIView {
|
|
|
470
470
|
contentExtent: entry.contentExtent(),
|
|
471
471
|
bounds: entry.bounds
|
|
472
472
|
)
|
|
473
|
+
// A fade-free exit does not animate alpha. If the fade-in was interrupted,
|
|
474
|
+
// the card would otherwise stay partly transparent and show the content
|
|
475
|
+
// behind it for the whole scale-out (OK-66647).
|
|
476
|
+
if !transition.hidesOpacity {
|
|
477
|
+
entry.contentView.alpha = 1
|
|
478
|
+
}
|
|
473
479
|
let contentAnimator = transition.motion.makeAnimator()
|
|
474
480
|
contentAnimator.addAnimations {
|
|
475
481
|
if transition.hidesOpacity {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Defaults match today's visuals: Dialog center (scale 0.85 + fade,
|
|
5
|
-
* Tamagui Sheet (slide from bottom, quick), message
|
|
6
|
-
* 300ms quad), Popover floating content (scale 0.95 +
|
|
4
|
+
* Defaults match today's visuals: Dialog center (scale 0.85 + fade in, then a
|
|
5
|
+
* fade-free scale 0.96 out), Tamagui Sheet (slide from bottom, quick), message
|
|
6
|
+
* toasts (slide from top, 300ms quad), Popover floating content (scale 0.95 +
|
|
7
|
+
* fade, popoverQuick).
|
|
8
|
+
*
|
|
9
|
+
* `exit` defaults to the presentation's own exit below; presentations without
|
|
10
|
+
* one mirror `enter`.
|
|
7
11
|
*/
|
|
8
12
|
export const DEFAULT_OVERLAY_ANIMATIONS = {
|
|
9
13
|
sheet: {
|
|
@@ -21,6 +25,17 @@ export const DEFAULT_OVERLAY_ANIMATIONS = {
|
|
|
21
25
|
fade: true,
|
|
22
26
|
motion: 'quick'
|
|
23
27
|
},
|
|
28
|
+
// OK-66647: the centered card is a solid surface. Fading it out lets any
|
|
29
|
+
// opaque content behind it (a text-heavy page, a list inside another
|
|
30
|
+
// overlay) show through the card for the whole transition, which reads as
|
|
31
|
+
// a doubled/ghosted render. Keep the card opaque while it shrinks and let
|
|
32
|
+
// the host unmount it at the end of the exit.
|
|
33
|
+
exit: {
|
|
34
|
+
type: 'scale',
|
|
35
|
+
scale: 0.96,
|
|
36
|
+
fade: false,
|
|
37
|
+
motion: 'quick'
|
|
38
|
+
},
|
|
24
39
|
backdrop: 'quick'
|
|
25
40
|
},
|
|
26
41
|
toast: {
|
|
@@ -68,7 +83,14 @@ export function resolveOverlayAnimation(presentation, animation, presets) {
|
|
|
68
83
|
const enterInput = animation?.enter ?? defaults.enter;
|
|
69
84
|
const fallbackMotion = defaults.enter.motion ?? 'quick';
|
|
70
85
|
const enter = resolveTransition(enterInput, fallbackMotion, presets);
|
|
71
|
-
|
|
86
|
+
// A caller-supplied enter keeps mirroring when its exit is omitted; the
|
|
87
|
+
// presentation default exit only applies when neither transition was
|
|
88
|
+
// customized.
|
|
89
|
+
const exitInput = animation?.exit ?? animation?.enter ?? defaults.exit ?? enterInput;
|
|
90
|
+
// A presentation default exit keeps its own fallback motion instead of
|
|
91
|
+
// inheriting the enter's.
|
|
92
|
+
const exitFallbackMotion = defaults.exit?.motion ?? fallbackMotion;
|
|
93
|
+
const exit = resolveTransition(exitInput, exitFallbackMotion, presets);
|
|
72
94
|
return {
|
|
73
95
|
enter,
|
|
74
96
|
exit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_OVERLAY_ANIMATIONS","sheet","enter","type","edge","motion","backdrop","center","scale","fade","toast","fullscreen","anchored","origin","resolveMotion","input","fallback","presets","value","resolveTransition","transition","fallbackMotion","resolveOverlayAnimation","presentation","animation","defaults","enterInput","
|
|
1
|
+
{"version":3,"names":["DEFAULT_OVERLAY_ANIMATIONS","sheet","enter","type","edge","motion","backdrop","center","scale","fade","exit","toast","fullscreen","anchored","origin","resolveMotion","input","fallback","presets","value","resolveTransition","transition","fallbackMotion","resolveOverlayAnimation","presentation","animation","defaults","enterInput","exitInput","exitFallbackMotion"],"sourceRoot":"../../../src","sources":["animation/resolveAnimation.ts"],"mappings":";;AAoBA;A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|
|
|
69
69
|
opacity: 1,
|
|
70
70
|
transform: 'translate3d(0, 0, 0) scale(1)'
|
|
71
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Keyframes for one enter/exit run. Pure so the interruption rules can be
|
|
74
|
+
* tested without a DOM.
|
|
75
|
+
*/
|
|
76
|
+
export function buildTransitionKeyframes({
|
|
77
|
+
transition,
|
|
78
|
+
extent,
|
|
79
|
+
direction,
|
|
80
|
+
sampled
|
|
81
|
+
}) {
|
|
82
|
+
const hidden = hiddenKeyframe(transition, extent);
|
|
83
|
+
const visible = {};
|
|
84
|
+
Object.keys(hidden).forEach(key => {
|
|
85
|
+
visible[key] = VISIBLE_KEYFRAME[key];
|
|
86
|
+
});
|
|
87
|
+
const initial = direction === 'in' ? hidden : visible;
|
|
88
|
+
const start = {};
|
|
89
|
+
Object.keys(initial).forEach(key => {
|
|
90
|
+
start[key] = sampled?.[key] ?? initial[key];
|
|
91
|
+
});
|
|
92
|
+
const end = direction === 'in' ? visible : hidden;
|
|
93
|
+
// A fade-free exit does not animate opacity. Drop a partly transparent frame
|
|
94
|
+
// left by an interrupted fade-in so the card stays opaque while it scales out
|
|
95
|
+
// (OK-66647).
|
|
96
|
+
if (direction === 'out' && hidden.opacity === undefined) {
|
|
97
|
+
start.opacity = 1;
|
|
98
|
+
end.opacity = 1;
|
|
99
|
+
}
|
|
100
|
+
return [start, end];
|
|
101
|
+
}
|
|
72
102
|
|
|
73
103
|
/**
|
|
74
104
|
* Runs an enter (`direction: 'in'`) or exit transition on `element`. The
|
|
@@ -91,18 +121,12 @@ export function animateTransition(element, contentRoot, transition, direction, i
|
|
|
91
121
|
const target = anchoredContent instanceof HTMLElement ? anchoredContent : element;
|
|
92
122
|
const targetRect = target === element ? undefined : target.getBoundingClientRect();
|
|
93
123
|
target.style.transformOrigin = `${(extent.left + extent.right) / 2 - (targetRect?.left ?? 0)}px ${(extent.top + extent.bottom) / 2 - (targetRect?.top ?? 0)}px`;
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const sampled = interruptedFrames?.get(target);
|
|
100
|
-
const initial = direction === 'in' ? hidden : visible;
|
|
101
|
-
const start = {};
|
|
102
|
-
Object.keys(initial).forEach(key => {
|
|
103
|
-
start[key] = sampled?.[key] ?? initial[key];
|
|
124
|
+
const keyframes = buildTransitionKeyframes({
|
|
125
|
+
transition: effective,
|
|
126
|
+
extent,
|
|
127
|
+
direction,
|
|
128
|
+
sampled: interruptedFrames?.get(target)
|
|
104
129
|
});
|
|
105
|
-
const keyframes = [start, direction === 'in' ? visible : hidden];
|
|
106
130
|
return target.animate(keyframes, {
|
|
107
131
|
...toTiming(effective.motion),
|
|
108
132
|
fill: 'forwards'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["springToCssLinear","measureContentExtent","container","rects","Array","from","children","map","child","getBoundingClientRect","length","top","bottom","window","innerHeight","left","right","innerWidth","Math","min","r","max","toTiming","motion","type","x1","y1","x2","y2","timing","easing","duration","durationMs","spring","prefersReducedMotion","globalThis","matchMedia","matches","hiddenKeyframe","transition","extent","frame","fade","opacity","edge","distance","transform","offsetY","scale","VISIBLE_KEYFRAME","
|
|
1
|
+
{"version":3,"names":["springToCssLinear","measureContentExtent","container","rects","Array","from","children","map","child","getBoundingClientRect","length","top","bottom","window","innerHeight","left","right","innerWidth","Math","min","r","max","toTiming","motion","type","x1","y1","x2","y2","timing","easing","duration","durationMs","spring","prefersReducedMotion","globalThis","matchMedia","matches","hiddenKeyframe","transition","extent","frame","fade","opacity","edge","distance","transform","offsetY","scale","VISIBLE_KEYFRAME","buildTransitionKeyframes","direction","sampled","hidden","visible","Object","keys","forEach","key","initial","start","end","undefined","animateTransition","element","contentRoot","interruptedFrames","effective","anchoredContent","origin","childElementCount","firstElementChild","target","HTMLElement","targetRect","style","transformOrigin","keyframes","get","animate","fill","animateBackdrop"],"sourceRoot":"../../../src","sources":["web/animateTransition.ts"],"mappings":";;AAAA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MAAM,CAACO,OAAO,CAACF,SAAS,EAAE;IAC/B,GAAGvD,QAAQ,CAAC6C,SAAS,CAAC5C,MAAM,CAAC;IAC7ByD,IAAI,EAAE;EACR,CAAC,CAAC;AACJ;AAEA,OAAO,SAASC,eAAeA,CAC7BjB,OAAoB,EACpBzC,MAAsB,EACtB4B,SAAuB,EACvBe,iBAAsD,EAC3C;EACX,MAAMd,OAAO,GAAGc,iBAAiB,EAAEY,GAAG,CAACd,OAAO,CAAC,EAAErB,OAAO;EACxD,MAAMkC,SAAS,GAAG,CAChB;IAAElC,OAAO,EAAES,OAAO,KAAKD,SAAS,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC;EAAE,CAAC,EACpD;IAAER,OAAO,EAAEQ,SAAS,KAAK,IAAI,GAAG,CAAC,GAAG;EAAE,CAAC,CACxC;EACD,OAAOa,OAAO,CAACe,OAAO,CAACF,SAAS,EAAE;IAAE,GAAGvD,QAAQ,CAACC,MAAM,CAAC;IAAEyD,IAAI,EAAE;EAAW,CAAC,CAAC;AAC9E","ignoreList":[]}
|
|
@@ -10,12 +10,18 @@ export interface IResolvedOverlayAnimation {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* Defaults match today's visuals: Dialog center (scale 0.85 + fade,
|
|
14
|
-
* Tamagui Sheet (slide from bottom, quick), message
|
|
15
|
-
* 300ms quad), Popover floating content (scale 0.95 +
|
|
13
|
+
* Defaults match today's visuals: Dialog center (scale 0.85 + fade in, then a
|
|
14
|
+
* fade-free scale 0.96 out), Tamagui Sheet (slide from bottom, quick), message
|
|
15
|
+
* toasts (slide from top, 300ms quad), Popover floating content (scale 0.95 +
|
|
16
|
+
* fade, popoverQuick).
|
|
17
|
+
*
|
|
18
|
+
* `exit` defaults to the presentation's own exit below; presentations without
|
|
19
|
+
* one mirror `enter`.
|
|
16
20
|
*/
|
|
17
21
|
export declare const DEFAULT_OVERLAY_ANIMATIONS: Record<IOverlayPresentation, {
|
|
18
22
|
enter: IOverlayTransition;
|
|
23
|
+
/** Mirrors `enter` when omitted. */
|
|
24
|
+
exit?: IOverlayTransition;
|
|
19
25
|
backdrop: IOverlayMotionPreset;
|
|
20
26
|
}>;
|
|
21
27
|
/** Fills presentation defaults and turns preset names into concrete curves. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAnimation.d.ts","sourceRoot":"","sources":["../../../../src/animation/resolveAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EAEd,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,0BACf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IAC1C,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,0BAA0B,CAAC;IAClC,IAAI,EAAE,0BAA0B,CAAC;IACjC,QAAQ,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC;CACtC;AAED
|
|
1
|
+
{"version":3,"file":"resolveAnimation.d.ts","sourceRoot":"","sources":["../../../../src/animation/resolveAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EAEd,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,0BACf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IAC1C,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,0BAA0B,CAAC;IAClC,IAAI,EAAE,0BAA0B,CAAC;IACjC,QAAQ,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC;CACtC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAC7C,oBAAoB,EACpB;IACE,KAAK,EAAE,kBAAkB,CAAC;IAC1B,oCAAoC;IACpC,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,EAAE,oBAAoB,CAAC;CAChC,CAkCF,CAAC;AAuBF,+EAA+E;AAC/E,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,oBAAoB,EAClC,SAAS,EAAE,iBAAiB,GAAG,SAAS,EACxC,OAAO,EAAE,MAAM,CAAC,oBAAoB,EAAE,cAAc,CAAC,GACpD,yBAAyB,CAyB3B"}
|
|
@@ -45,7 +45,11 @@ export interface IOverlayTransition {
|
|
|
45
45
|
}
|
|
46
46
|
export interface IOverlayAnimation {
|
|
47
47
|
enter?: IOverlayTransition;
|
|
48
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Defaults to the presentation's default exit (see
|
|
50
|
+
* `DEFAULT_OVERLAY_ANIMATIONS`), or the reverse of `enter` when the
|
|
51
|
+
* presentation has no default exit.
|
|
52
|
+
*/
|
|
49
53
|
exit?: IOverlayTransition;
|
|
50
54
|
/** Backdrop fade; runs on the same clock as the content by default. */
|
|
51
55
|
backdrop?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/animation/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5E,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,QAAQ,CAAC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AuE;IACvE,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,mBAAmB,CAAA;KAAE,CAAC;CAC7C;AAED,MAAM,MAAM,oBAAoB,GAC5B,OAAO,GACP,QAAQ,GACR,YAAY,GACZ,OAAO,GACP,UAAU,CAAC"}
|
|
@@ -8,6 +8,18 @@ export interface IContentExtent {
|
|
|
8
8
|
}
|
|
9
9
|
/** Union of the rendered children rects; the content wrapper is full-window. */
|
|
10
10
|
export declare function measureContentExtent(container: HTMLElement): IContentExtent;
|
|
11
|
+
export interface ITransitionKeyframeInput {
|
|
12
|
+
transition: IResolvedOverlayTransition;
|
|
13
|
+
extent: IContentExtent;
|
|
14
|
+
direction: 'in' | 'out';
|
|
15
|
+
/** Rendered frames of an interrupted run; the new run starts from them. */
|
|
16
|
+
sampled?: Keyframe;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Keyframes for one enter/exit run. Pure so the interruption rules can be
|
|
20
|
+
* tested without a DOM.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildTransitionKeyframes({ transition, extent, direction, sampled, }: ITransitionKeyframeInput): [Keyframe, Keyframe];
|
|
11
23
|
/**
|
|
12
24
|
* Runs an enter (`direction: 'in'`) or exit transition on `element`. The
|
|
13
25
|
* slide distance and scale origin come from the children of `contentRoot`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animateTransition.d.ts","sourceRoot":"","sources":["../../../../src/web/animateTransition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,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W,CAAC,WAAW,EAAE,QAAQ,CAAC,GACrD,SAAS,GAAG,SAAS,CA+BvB;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,IAAI,GAAG,KAAK,EACvB,iBAAiB,CAAC,EAAE,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,GACrD,SAAS,CAOX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-native-overlay",
|
|
3
|
-
"version": "6.7.0-
|
|
3
|
+
"version": "6.7.0-32",
|
|
4
4
|
"description": "Native and Web overlay hosts with ordered levels, page scope and Fabric measurement",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -19,13 +19,22 @@ export interface IResolvedOverlayAnimation {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Defaults match today's visuals: Dialog center (scale 0.85 + fade,
|
|
23
|
-
* Tamagui Sheet (slide from bottom, quick), message
|
|
24
|
-
* 300ms quad), Popover floating content (scale 0.95 +
|
|
22
|
+
* Defaults match today's visuals: Dialog center (scale 0.85 + fade in, then a
|
|
23
|
+
* fade-free scale 0.96 out), Tamagui Sheet (slide from bottom, quick), message
|
|
24
|
+
* toasts (slide from top, 300ms quad), Popover floating content (scale 0.95 +
|
|
25
|
+
* fade, popoverQuick).
|
|
26
|
+
*
|
|
27
|
+
* `exit` defaults to the presentation's own exit below; presentations without
|
|
28
|
+
* one mirror `enter`.
|
|
25
29
|
*/
|
|
26
30
|
export const DEFAULT_OVERLAY_ANIMATIONS: Record<
|
|
27
31
|
IOverlayPresentation,
|
|
28
|
-
{
|
|
32
|
+
{
|
|
33
|
+
enter: IOverlayTransition;
|
|
34
|
+
/** Mirrors `enter` when omitted. */
|
|
35
|
+
exit?: IOverlayTransition;
|
|
36
|
+
backdrop: IOverlayMotionPreset;
|
|
37
|
+
}
|
|
29
38
|
> = {
|
|
30
39
|
sheet: {
|
|
31
40
|
enter: { type: 'slide', edge: 'bottom', motion: 'quick' },
|
|
@@ -33,6 +42,12 @@ export const DEFAULT_OVERLAY_ANIMATIONS: Record<
|
|
|
33
42
|
},
|
|
34
43
|
center: {
|
|
35
44
|
enter: { type: 'scale', scale: 0.85, fade: true, motion: 'quick' },
|
|
45
|
+
// OK-66647: the centered card is a solid surface. Fading it out lets any
|
|
46
|
+
// opaque content behind it (a text-heavy page, a list inside another
|
|
47
|
+
// overlay) show through the card for the whole transition, which reads as
|
|
48
|
+
// a doubled/ghosted render. Keep the card opaque while it shrinks and let
|
|
49
|
+
// the host unmount it at the end of the exit.
|
|
50
|
+
exit: { type: 'scale', scale: 0.96, fade: false, motion: 'quick' },
|
|
36
51
|
backdrop: 'quick',
|
|
37
52
|
},
|
|
38
53
|
toast: {
|
|
@@ -86,9 +101,15 @@ export function resolveOverlayAnimation(
|
|
|
86
101
|
const enterInput = animation?.enter ?? defaults.enter;
|
|
87
102
|
const fallbackMotion = defaults.enter.motion ?? 'quick';
|
|
88
103
|
const enter = resolveTransition(enterInput, fallbackMotion, presets);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
// A caller-supplied enter keeps mirroring when its exit is omitted; the
|
|
105
|
+
// presentation default exit only applies when neither transition was
|
|
106
|
+
// customized.
|
|
107
|
+
const exitInput =
|
|
108
|
+
animation?.exit ?? animation?.enter ?? defaults.exit ?? enterInput;
|
|
109
|
+
// A presentation default exit keeps its own fallback motion instead of
|
|
110
|
+
// inheriting the enter's.
|
|
111
|
+
const exitFallbackMotion = defaults.exit?.motion ?? fallbackMotion;
|
|
112
|
+
const exit = resolveTransition(exitInput, exitFallbackMotion, presets);
|
|
92
113
|
return {
|
|
93
114
|
enter,
|
|
94
115
|
exit,
|
package/src/animation/types.ts
CHANGED
|
@@ -57,7 +57,11 @@ export interface IOverlayTransition {
|
|
|
57
57
|
|
|
58
58
|
export interface IOverlayAnimation {
|
|
59
59
|
enter?: IOverlayTransition;
|
|
60
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Defaults to the presentation's default exit (see
|
|
62
|
+
* `DEFAULT_OVERLAY_ANIMATIONS`), or the reverse of `enter` when the
|
|
63
|
+
* presentation has no default exit.
|
|
64
|
+
*/
|
|
61
65
|
exit?: IOverlayTransition;
|
|
62
66
|
/** Backdrop fade; runs on the same clock as the content by default. */
|
|
63
67
|
backdrop?: { motion?: IOverlayMotionInput };
|
|
@@ -91,6 +91,45 @@ const VISIBLE_KEYFRAME: Keyframe = {
|
|
|
91
91
|
transform: 'translate3d(0, 0, 0) scale(1)',
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
export interface ITransitionKeyframeInput {
|
|
95
|
+
transition: IResolvedOverlayTransition;
|
|
96
|
+
extent: IContentExtent;
|
|
97
|
+
direction: 'in' | 'out';
|
|
98
|
+
/** Rendered frames of an interrupted run; the new run starts from them. */
|
|
99
|
+
sampled?: Keyframe;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Keyframes for one enter/exit run. Pure so the interruption rules can be
|
|
104
|
+
* tested without a DOM.
|
|
105
|
+
*/
|
|
106
|
+
export function buildTransitionKeyframes({
|
|
107
|
+
transition,
|
|
108
|
+
extent,
|
|
109
|
+
direction,
|
|
110
|
+
sampled,
|
|
111
|
+
}: ITransitionKeyframeInput): [Keyframe, Keyframe] {
|
|
112
|
+
const hidden = hiddenKeyframe(transition, extent);
|
|
113
|
+
const visible: Keyframe = {};
|
|
114
|
+
Object.keys(hidden).forEach((key) => {
|
|
115
|
+
visible[key] = VISIBLE_KEYFRAME[key];
|
|
116
|
+
});
|
|
117
|
+
const initial = direction === 'in' ? hidden : visible;
|
|
118
|
+
const start: Keyframe = {};
|
|
119
|
+
Object.keys(initial).forEach((key) => {
|
|
120
|
+
start[key] = sampled?.[key] ?? initial[key];
|
|
121
|
+
});
|
|
122
|
+
const end: Keyframe = direction === 'in' ? visible : hidden;
|
|
123
|
+
// A fade-free exit does not animate opacity. Drop a partly transparent frame
|
|
124
|
+
// left by an interrupted fade-in so the card stays opaque while it scales out
|
|
125
|
+
// (OK-66647).
|
|
126
|
+
if (direction === 'out' && hidden.opacity === undefined) {
|
|
127
|
+
start.opacity = 1;
|
|
128
|
+
end.opacity = 1;
|
|
129
|
+
}
|
|
130
|
+
return [start, end];
|
|
131
|
+
}
|
|
132
|
+
|
|
94
133
|
/**
|
|
95
134
|
* Runs an enter (`direction: 'in'`) or exit transition on `element`. The
|
|
96
135
|
* slide distance and scale origin come from the children of `contentRoot`,
|
|
@@ -123,18 +162,12 @@ export function animateTransition(
|
|
|
123
162
|
target.style.transformOrigin = `${
|
|
124
163
|
(extent.left + extent.right) / 2 - (targetRect?.left ?? 0)
|
|
125
164
|
}px ${(extent.top + extent.bottom) / 2 - (targetRect?.top ?? 0)}px`;
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const sampled = interruptedFrames?.get(target);
|
|
132
|
-
const initial = direction === 'in' ? hidden : visible;
|
|
133
|
-
const start: Keyframe = {};
|
|
134
|
-
Object.keys(initial).forEach((key) => {
|
|
135
|
-
start[key] = sampled?.[key] ?? initial[key];
|
|
165
|
+
const keyframes = buildTransitionKeyframes({
|
|
166
|
+
transition: effective,
|
|
167
|
+
extent,
|
|
168
|
+
direction,
|
|
169
|
+
sampled: interruptedFrames?.get(target),
|
|
136
170
|
});
|
|
137
|
-
const keyframes = [start, direction === 'in' ? visible : hidden];
|
|
138
171
|
return target.animate(keyframes, {
|
|
139
172
|
...toTiming(effective.motion),
|
|
140
173
|
fill: 'forwards',
|