react-native-nitro-modal 0.3.8-rc → 1.0.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 +2 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/BottomSheetPresenter.kt +8 -30
- package/android/src/main/java/com/margelo/nitro/nitromodal/HybridNitroModal.kt +0 -2
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalContentRoot.kt +83 -4
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalPresenter.kt +0 -2
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalHostView.kt +1 -3
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalViewManager.kt +0 -2
- package/ios/HybridNitroModal.swift +0 -1
- package/ios/HybridNitroModalComponent+Children.mm +59 -1
- package/ios/ModalConfig.swift +0 -1
- package/ios/NitroModalHostView.swift +0 -1
- package/ios/PopupViewController.swift +0 -1
- package/ios/SheetView.swift +0 -5
- package/lib/module/NitroModalView.js +0 -5
- package/lib/module/NitroModalView.js.map +1 -1
- package/lib/module/NitroModalView.web.js +0 -2
- package/lib/module/NitroModalView.web.js.map +1 -1
- package/lib/module/web/AnimatedValue.js +0 -4
- package/lib/module/web/AnimatedValue.js.map +1 -1
- package/lib/module/web/ModalConfig.js.map +1 -1
- package/lib/module/web/ModalController.js +0 -16
- package/lib/module/web/ModalController.js.map +1 -1
- package/lib/module/web/ModalPresenter.js +47 -3
- package/lib/module/web/ModalPresenter.js.map +1 -1
- package/lib/module/web/SheetPresenter.js +16 -17
- package/lib/module/web/SheetPresenter.js.map +1 -1
- package/lib/module/web/dom.js +0 -4
- package/lib/module/web/dom.js.map +1 -1
- package/lib/typescript/src/NitroModal.nitro.d.ts +0 -2
- package/lib/typescript/src/NitroModal.nitro.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.web.d.ts.map +1 -1
- package/lib/typescript/src/web/AnimatedValue.d.ts +0 -2
- package/lib/typescript/src/web/AnimatedValue.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalConfig.d.ts +0 -1
- package/lib/typescript/src/web/ModalConfig.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalController.d.ts +0 -3
- package/lib/typescript/src/web/ModalController.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalPresenter.d.ts +17 -3
- package/lib/typescript/src/web/ModalPresenter.d.ts.map +1 -1
- package/lib/typescript/src/web/SheetPresenter.d.ts +1 -6
- package/lib/typescript/src/web/SheetPresenter.d.ts.map +1 -1
- package/lib/typescript/src/web/dom.d.ts +0 -2
- package/lib/typescript/src/web/dom.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NitroModal.nitro.ts +0 -2
- package/src/NitroModalView.tsx +0 -4
- package/src/NitroModalView.web.tsx +0 -2
- package/src/web/AnimatedValue.ts +0 -2
- package/src/web/ModalConfig.ts +0 -1
- package/src/web/ModalController.ts +0 -11
- package/src/web/ModalPresenter.ts +48 -5
- package/src/web/SheetPresenter.ts +17 -12
- package/src/web/dom.ts +0 -2
|
@@ -7,7 +7,6 @@ export interface ModalElements {
|
|
|
7
7
|
backdrop: HTMLElement;
|
|
8
8
|
/** The sheet or the popup card. */
|
|
9
9
|
surface: HTMLElement;
|
|
10
|
-
/** Hosts the React content. */
|
|
11
10
|
content: HTMLElement;
|
|
12
11
|
grabber: HTMLElement;
|
|
13
12
|
/** Above the content, following the surface's corners. */
|
|
@@ -23,7 +22,6 @@ export interface PresenterListener {
|
|
|
23
22
|
/** The exit transition finished. Called at most once per presenter. */
|
|
24
23
|
onDismissed(): void;
|
|
25
24
|
onBackdropPress(): void;
|
|
26
|
-
/** The user swiped the sheet down far enough to dismiss it. */
|
|
27
25
|
onSwipeDismiss(): void;
|
|
28
26
|
onDetentChange(index: number): void;
|
|
29
27
|
onContentAreaChange(width: number, height: number): void;
|
|
@@ -51,10 +49,18 @@ export declare abstract class ModalPresenter {
|
|
|
51
49
|
protected insets: Insets;
|
|
52
50
|
/** Part of the viewport covered by the on-screen keyboard, from the bottom. */
|
|
53
51
|
protected keyboardHeight: number;
|
|
54
|
-
/** Measured size of the React content. */
|
|
55
52
|
protected contentSize: Size;
|
|
56
53
|
protected entering: boolean;
|
|
57
54
|
protected isDismissing: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Inline: the elements are in the document but not rendered, e.g. on a
|
|
57
|
+
* screen that navigation hid with `display: none` while another one is on
|
|
58
|
+
* top. They measure 0 × 0 then, so the last layout is kept for when they
|
|
59
|
+
* come back instead of collapsing the sheet.
|
|
60
|
+
*/
|
|
61
|
+
private hidden;
|
|
62
|
+
/** Rendered at least once since `show`. */
|
|
63
|
+
private hasAppeared;
|
|
58
64
|
private finished;
|
|
59
65
|
private observedContent;
|
|
60
66
|
private resizeObserver;
|
|
@@ -89,6 +95,12 @@ export declare abstract class ModalPresenter {
|
|
|
89
95
|
protected abstract configDidChange(previous: ModalConfig): void;
|
|
90
96
|
/** The viewport size, safe area or keyboard height changed. */
|
|
91
97
|
protected abstract viewportDidChange(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Inline: the elements are rendered again after being hidden, with the
|
|
100
|
+
* viewport already re-measured. `firstAppearance`: they were hidden since
|
|
101
|
+
* `show`, so the enter hasn't been seen yet.
|
|
102
|
+
*/
|
|
103
|
+
protected viewportDidReappear(firstAppearance: boolean): void;
|
|
92
104
|
protected abstract contentSizeDidChange(): void;
|
|
93
105
|
protected abstract stopAnimations(): void;
|
|
94
106
|
/** For subclasses: the running enter animation settled. */
|
|
@@ -102,6 +114,8 @@ export declare abstract class ModalPresenter {
|
|
|
102
114
|
private measureViewport;
|
|
103
115
|
/** Re-targets the observer at the content's root element. Returns whether its size changed. */
|
|
104
116
|
private observeContent;
|
|
117
|
+
/** False under `display: none` (e.g. a hidden navigation screen) or once detached. */
|
|
118
|
+
private isRendered;
|
|
105
119
|
private measureContent;
|
|
106
120
|
private handleContentResize;
|
|
107
121
|
private handleResize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalPresenter.d.ts","sourceRoot":"","sources":["../../../../src/web/ModalPresenter.ts"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,MAAM,EACX,KAAK,IAAI,EACV,MAAM,UAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAEjD,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,WAAW,CAAC;IACtB,mCAAmC;IACnC,OAAO,EAAE,WAAW,CAAC;IACrB
|
|
1
|
+
{"version":3,"file":"ModalPresenter.d.ts","sourceRoot":"","sources":["../../../../src/web/ModalPresenter.ts"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,MAAM,EACX,KAAK,IAAI,EACV,MAAM,UAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAEjD,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,WAAW,CAAC;IACtB,mCAAmC;IACnC,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;IACrB,0DAA0D;IAC1D,MAAM,EAAE,WAAW,CAAC;IACpB,qFAAqF;IACrF,gBAAgB,EAAE,WAAW,CAAC;IAC9B,mDAAmD;IACnD,cAAc,EAAE,WAAW,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,WAAW,IAAI,IAAI,CAAC;IACpB,uEAAuE;IACvE,WAAW,IAAI,IAAI,CAAC;IACpB,eAAe,IAAI,IAAI,CAAC;IACxB,cAAc,IAAI,IAAI,CAAC;IACvB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,mBA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,CAAC,SAAS,IAAI,IAAI;IAEpC,wFAAwF;IACxF,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI;IAEtD,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;IAE/D,+DAA+D;IAC/D,SAAS,CAAC,QAAQ,CAAC,iBAAiB,IAAI,IAAI;IAE5C;;;;OAIG;IACH,SAAS,CAAC,mBAAmB,CAAC,eAAe,EAAE,OAAO;IAOtD,SAAS,CAAC,QAAQ,CAAC,oBAAoB,IAAI,IAAI;IAE/C,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI;IAEzC,2DAA2D;IAC3D,SAAS,CAAC,eAAe;IAMzB,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMzD,SAAS,CAAC,QAAQ;IAiBlB,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,aAAa;IA0BrB,uEAAuE;IACvE,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,eAAe;IAevB,+FAA+F;IAC/F,OAAO,CAAC,cAAc;IAetB,sFAAsF;IACtF,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,mBAAmB,CAIzB;IAEF,OAAO,CAAC,YAAY,CAgBlB;IAEF,OAAO,CAAC,cAAc,CAMpB;IAEF,OAAO,CAAC,mBAAmB,CAIzB;IAEF,wFAAwF;IACxF,OAAO,CAAC,WAAW,CAMjB;CACH"}
|
|
@@ -16,7 +16,6 @@ export declare class SheetPresenter extends ModalPresenter {
|
|
|
16
16
|
private drag;
|
|
17
17
|
/** Vertical velocity of the swipe that requested the dismissal. */
|
|
18
18
|
private releaseVelocity;
|
|
19
|
-
/** The sheet rests below its lowest detent, the indicator spinning above it. */
|
|
20
19
|
private refreshing;
|
|
21
20
|
private refreshSpin;
|
|
22
21
|
/** The sheet's top edge in the viewport. */
|
|
@@ -28,6 +27,7 @@ export declare class SheetPresenter extends ModalPresenter {
|
|
|
28
27
|
protected animateOut(onEnd: () => void): void;
|
|
29
28
|
protected configDidChange(previous: ModalConfig): void;
|
|
30
29
|
protected viewportDidChange(): void;
|
|
30
|
+
protected viewportDidReappear(firstAppearance: boolean): void;
|
|
31
31
|
protected contentSizeDidChange(): void;
|
|
32
32
|
protected stopAnimations(): void;
|
|
33
33
|
protected teardown(): void;
|
|
@@ -38,7 +38,6 @@ export declare class SheetPresenter extends ModalPresenter {
|
|
|
38
38
|
/** Sheet top when resting on `detents[index]`. The bottom safe area is added below the content. */
|
|
39
39
|
private restingTop;
|
|
40
40
|
private get detentTops();
|
|
41
|
-
/** Where the sheet settles on `detents[index]`: held below the lowest detent while refreshing. */
|
|
42
41
|
private settledTop;
|
|
43
42
|
private get settledTops();
|
|
44
43
|
private layout;
|
|
@@ -49,10 +48,6 @@ export declare class SheetPresenter extends ModalPresenter {
|
|
|
49
48
|
* indicator at the top of the sheet.
|
|
50
49
|
*/
|
|
51
50
|
private split;
|
|
52
|
-
/**
|
|
53
|
-
* Centered in the gap a pull uncovers above the content, fading in as the
|
|
54
|
-
* pull nears the threshold.
|
|
55
|
-
*/
|
|
56
51
|
private renderRefreshIndicator;
|
|
57
52
|
/** Fully dimmed at every detent; fades out below the lowest one. */
|
|
58
53
|
private backdropAlpha;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetPresenter.d.ts","sourceRoot":"","sources":["../../../../src/web/SheetPresenter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAqB,CAAC;AAEvD,OAAO,EAOL,KAAK,MAAM,EACX,KAAK,IAAI,EACV,MAAM,UAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAkB,CAAC;AAmG1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AO,CAAC,eAAe,CAqBrB;IAEF,OAAO,CAAC,cAAc,CAKpB;IAEF,OAAO,CAAC,iBAAiB,CAqBvB;IAEF,OAAO,CAAC,iBAAiB,CAkBvB;IAEF,OAAO,CAAC,eAAe,CAIrB;CACH"}
|
|
@@ -10,7 +10,6 @@ export interface Insets {
|
|
|
10
10
|
}
|
|
11
11
|
export declare const ZERO_INSETS: Insets;
|
|
12
12
|
export declare const canUseDOM: boolean;
|
|
13
|
-
/** Width and height of the pull-to-refresh indicator. */
|
|
14
13
|
export declare const REFRESH_INDICATOR_SIZE = 24;
|
|
15
14
|
/** Converts a color from `processColor` (0xAARRGGBB) to CSS, scaling its alpha by `opacity`. */
|
|
16
15
|
export declare function toCSSColor(argb: number, opacity?: number): string;
|
|
@@ -26,7 +25,6 @@ export declare function inlineInsets(element: Element): Insets;
|
|
|
26
25
|
* Mobile browsers keep the layout viewport and shrink the visual one.
|
|
27
26
|
*/
|
|
28
27
|
export declare function readKeyboardHeight(layoutHeight: number): number;
|
|
29
|
-
/** The size of the viewport before anything is on screen. */
|
|
30
28
|
export declare function estimateViewport(): Size;
|
|
31
29
|
/** The innermost element from `target` up to (not including) `root` that scrolls vertically. */
|
|
32
30
|
export declare function findVerticalScroller(target: EventTarget | null, root: Element): HTMLElement | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../../src/web/dom.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,WAAW,EAAE,MAAiD,CAAC;AAE5E,eAAO,MAAM,SAAS,SAC4C,CAAC;AAEnE,
|
|
1
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,IAAI,MAAM,CAMrC"}
|
package/package.json
CHANGED
package/src/NitroModal.nitro.ts
CHANGED
|
@@ -41,7 +41,6 @@ export type KeyboardBehavior = 'pan' | 'resize' | 'none';
|
|
|
41
41
|
/** Enter/exit transition of a `popup`. */
|
|
42
42
|
export type PopupAnimation = 'scale' | 'fade' | 'none';
|
|
43
43
|
|
|
44
|
-
/** What caused the modal to close. */
|
|
45
44
|
export type DismissReason =
|
|
46
45
|
'programmatic' | 'swipe' | 'backdrop' | 'backButton';
|
|
47
46
|
|
|
@@ -52,7 +51,6 @@ export interface ModalContentArea {
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
export interface NitroModalProps extends HybridViewProps {
|
|
55
|
-
/** Whether the modal should be presented. */
|
|
56
54
|
isOpen: boolean;
|
|
57
55
|
mode: ModalMode;
|
|
58
56
|
/**
|
package/src/NitroModalView.tsx
CHANGED
|
@@ -6,10 +6,6 @@ import type { NitroModalMethods, NitroModalProps } from './NitroModal.nitro';
|
|
|
6
6
|
|
|
7
7
|
let warned = false;
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Platforms without an implementation render nothing. iOS and Android use
|
|
11
|
-
* `NitroModalView.native.tsx`, web uses `NitroModalView.web.tsx`.
|
|
12
|
-
*/
|
|
13
9
|
function UnsupportedNitroModalView() {
|
|
14
10
|
if (!warned) {
|
|
15
11
|
warned = true;
|
|
@@ -145,7 +145,6 @@ const styles = {
|
|
|
145
145
|
inset: 0,
|
|
146
146
|
outline: 'none',
|
|
147
147
|
},
|
|
148
|
-
// Fills the host view; the sheet hides below its bottom edge.
|
|
149
148
|
inlineOverlay: {
|
|
150
149
|
position: 'absolute',
|
|
151
150
|
inset: 0,
|
|
@@ -182,7 +181,6 @@ const styles = {
|
|
|
182
181
|
backgroundColor: 'rgba(127, 127, 127, 0.4)',
|
|
183
182
|
pointerEvents: 'none',
|
|
184
183
|
},
|
|
185
|
-
// Sized by the presenter's border width; follows the surface's corners.
|
|
186
184
|
border: {
|
|
187
185
|
position: 'absolute',
|
|
188
186
|
inset: 0,
|
package/src/web/AnimatedValue.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
|
|
3
|
-
/** How an `AnimatedValue` moves to its target. */
|
|
4
3
|
export type Motion =
|
|
5
4
|
| {
|
|
6
5
|
type: 'spring';
|
|
@@ -75,7 +74,6 @@ export class AnimatedValue {
|
|
|
75
74
|
return this.run != null;
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
/** Jumps to `value`, cancelling any animation. */
|
|
79
77
|
set(value: number) {
|
|
80
78
|
this.stop();
|
|
81
79
|
this.current = value;
|
package/src/web/ModalConfig.ts
CHANGED
|
@@ -26,7 +26,6 @@ export interface ModalConfig {
|
|
|
26
26
|
grabberVisible: boolean;
|
|
27
27
|
/** `null` uses the default. */
|
|
28
28
|
cornerRadius: number | null;
|
|
29
|
-
/** Border around the surface, drawn above the content. */
|
|
30
29
|
borderWidth: number;
|
|
31
30
|
/** 0xAARRGGBB; `null` draws no border. */
|
|
32
31
|
borderColor: number | null;
|
|
@@ -56,7 +56,6 @@ export class ModalController implements PresenterListener {
|
|
|
56
56
|
private wantsOpen = false;
|
|
57
57
|
/** A present request was accepted and its `onDismiss` is still owed. */
|
|
58
58
|
private sessionActive = false;
|
|
59
|
-
/** `onPresent` was sent for the current session. */
|
|
60
59
|
private presentSent = false;
|
|
61
60
|
private dismissReason: DismissReason = 'programmatic';
|
|
62
61
|
private reconcileScheduled = false;
|
|
@@ -70,8 +69,6 @@ export class ModalController implements PresenterListener {
|
|
|
70
69
|
/** `setMounted` renders (or removes) the modal's elements. */
|
|
71
70
|
constructor(private readonly setMounted: (mounted: boolean) => void) {}
|
|
72
71
|
|
|
73
|
-
// Host view lifecycle
|
|
74
|
-
|
|
75
72
|
attach() {
|
|
76
73
|
this.isAttached = true;
|
|
77
74
|
window.addEventListener('resize', this.handleWindowResize);
|
|
@@ -95,7 +92,6 @@ export class ModalController implements PresenterListener {
|
|
|
95
92
|
this.setMounted(false);
|
|
96
93
|
}
|
|
97
94
|
|
|
98
|
-
/** The host view rendered with new props. */
|
|
99
95
|
update(props: NitroModalProps) {
|
|
100
96
|
this.props = props;
|
|
101
97
|
const next = makeConfig(props);
|
|
@@ -117,7 +113,6 @@ export class ModalController implements PresenterListener {
|
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
115
|
|
|
120
|
-
/** Inline: the element the sheet fills, rendered in place. */
|
|
121
116
|
hostDidChange(host: HTMLElement | null) {
|
|
122
117
|
if (host === this.host) return;
|
|
123
118
|
this.host = host;
|
|
@@ -151,8 +146,6 @@ export class ModalController implements PresenterListener {
|
|
|
151
146
|
this.reconcile();
|
|
152
147
|
};
|
|
153
148
|
|
|
154
|
-
// State machine
|
|
155
|
-
|
|
156
149
|
private get isVisible(): boolean {
|
|
157
150
|
return this.phase === 'presenting' || this.phase === 'presented';
|
|
158
151
|
}
|
|
@@ -256,8 +249,6 @@ export class ModalController implements PresenterListener {
|
|
|
256
249
|
}
|
|
257
250
|
}
|
|
258
251
|
|
|
259
|
-
// PresenterListener
|
|
260
|
-
|
|
261
252
|
onPresented() {
|
|
262
253
|
if (this.phase !== 'presenting') return;
|
|
263
254
|
this.phase = 'presented';
|
|
@@ -302,8 +293,6 @@ export class ModalController implements PresenterListener {
|
|
|
302
293
|
this.props?.onContentAreaChange?.(area);
|
|
303
294
|
}
|
|
304
295
|
|
|
305
|
-
// Helpers
|
|
306
|
-
|
|
307
296
|
/** Lets React size the content before the first presentation. */
|
|
308
297
|
private reportEstimatedContentArea() {
|
|
309
298
|
const { config } = this;
|
|
@@ -20,7 +20,6 @@ export interface ModalElements {
|
|
|
20
20
|
backdrop: HTMLElement;
|
|
21
21
|
/** The sheet or the popup card. */
|
|
22
22
|
surface: HTMLElement;
|
|
23
|
-
/** Hosts the React content. */
|
|
24
23
|
content: HTMLElement;
|
|
25
24
|
grabber: HTMLElement;
|
|
26
25
|
/** Above the content, following the surface's corners. */
|
|
@@ -37,7 +36,6 @@ export interface PresenterListener {
|
|
|
37
36
|
/** The exit transition finished. Called at most once per presenter. */
|
|
38
37
|
onDismissed(): void;
|
|
39
38
|
onBackdropPress(): void;
|
|
40
|
-
/** The user swiped the sheet down far enough to dismiss it. */
|
|
41
39
|
onSwipeDismiss(): void;
|
|
42
40
|
onDetentChange(index: number): void;
|
|
43
41
|
onContentAreaChange(width: number, height: number): void;
|
|
@@ -64,10 +62,18 @@ export abstract class ModalPresenter {
|
|
|
64
62
|
protected insets: Insets = ZERO_INSETS;
|
|
65
63
|
/** Part of the viewport covered by the on-screen keyboard, from the bottom. */
|
|
66
64
|
protected keyboardHeight = 0;
|
|
67
|
-
/** Measured size of the React content. */
|
|
68
65
|
protected contentSize: Size = { width: 0, height: 0 };
|
|
69
66
|
protected entering = false;
|
|
70
67
|
protected isDismissing = false;
|
|
68
|
+
/**
|
|
69
|
+
* Inline: the elements are in the document but not rendered, e.g. on a
|
|
70
|
+
* screen that navigation hid with `display: none` while another one is on
|
|
71
|
+
* top. They measure 0 × 0 then, so the last layout is kept for when they
|
|
72
|
+
* come back instead of collapsing the sheet.
|
|
73
|
+
*/
|
|
74
|
+
private hidden = false;
|
|
75
|
+
/** Rendered at least once since `show`. */
|
|
76
|
+
private hasAppeared = false;
|
|
71
77
|
private finished = false;
|
|
72
78
|
private observedContent: HTMLElement | null = null;
|
|
73
79
|
private resizeObserver: ResizeObserver | null = null;
|
|
@@ -112,12 +118,17 @@ export abstract class ModalPresenter {
|
|
|
112
118
|
this.resizeObserver = new ResizeObserver(this.handleContentResize);
|
|
113
119
|
}
|
|
114
120
|
|
|
121
|
+
this.hidden = this.config.isInline && !this.isRendered();
|
|
122
|
+
this.hasAppeared = !this.hidden;
|
|
115
123
|
this.measureViewport();
|
|
116
124
|
this.observeContent();
|
|
117
125
|
this.applyBackdrop();
|
|
118
126
|
this.didShow();
|
|
119
127
|
this.entering = true;
|
|
120
|
-
|
|
128
|
+
// Hidden: the enter plays once the sheet can be seen (`viewportDidReappear`).
|
|
129
|
+
if (!this.hidden) {
|
|
130
|
+
this.animateIn();
|
|
131
|
+
}
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
update(config: ModalConfig) {
|
|
@@ -189,6 +200,18 @@ export abstract class ModalPresenter {
|
|
|
189
200
|
/** The viewport size, safe area or keyboard height changed. */
|
|
190
201
|
protected abstract viewportDidChange(): void;
|
|
191
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Inline: the elements are rendered again after being hidden, with the
|
|
205
|
+
* viewport already re-measured. `firstAppearance`: they were hidden since
|
|
206
|
+
* `show`, so the enter hasn't been seen yet.
|
|
207
|
+
*/
|
|
208
|
+
protected viewportDidReappear(firstAppearance: boolean) {
|
|
209
|
+
this.viewportDidChange();
|
|
210
|
+
if (firstAppearance && this.entering) {
|
|
211
|
+
this.animateIn();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
192
215
|
protected abstract contentSizeDidChange(): void;
|
|
193
216
|
|
|
194
217
|
protected abstract stopAnimations(): void;
|
|
@@ -298,7 +321,15 @@ export abstract class ModalPresenter {
|
|
|
298
321
|
return this.measureContent();
|
|
299
322
|
}
|
|
300
323
|
|
|
324
|
+
/** False under `display: none` (e.g. a hidden navigation screen) or once detached. */
|
|
325
|
+
private isRendered(): boolean {
|
|
326
|
+
return this.elements!.overlay.getClientRects().length > 0;
|
|
327
|
+
}
|
|
328
|
+
|
|
301
329
|
private measureContent(): boolean {
|
|
330
|
+
// Hidden content measures 0 × 0; its last size stands until it's back.
|
|
331
|
+
// Checked directly too, as this observer can fire before the host's.
|
|
332
|
+
if (this.hidden || !this.isRendered()) return false;
|
|
302
333
|
// Layout sizes, unaffected by the transition's transforms.
|
|
303
334
|
const width = this.observedContent?.offsetWidth ?? 0;
|
|
304
335
|
const height = this.observedContent?.offsetHeight ?? 0;
|
|
@@ -316,8 +347,20 @@ export abstract class ModalPresenter {
|
|
|
316
347
|
|
|
317
348
|
private handleResize = () => {
|
|
318
349
|
if (!this.elements) return;
|
|
350
|
+
if (this.config.isInline && !this.isRendered()) {
|
|
351
|
+
this.hidden = true;
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
319
354
|
this.measureViewport();
|
|
320
|
-
this.
|
|
355
|
+
if (!this.hidden) {
|
|
356
|
+
this.viewportDidChange();
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
this.hidden = false;
|
|
360
|
+
const firstAppearance = !this.hasAppeared;
|
|
361
|
+
this.hasAppeared = true;
|
|
362
|
+
this.measureContent();
|
|
363
|
+
this.viewportDidReappear(firstAppearance);
|
|
321
364
|
};
|
|
322
365
|
|
|
323
366
|
private handleKeyboard = () => {
|
|
@@ -152,7 +152,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
152
152
|
private drag: Drag | null = null;
|
|
153
153
|
/** Vertical velocity of the swipe that requested the dismissal. */
|
|
154
154
|
private releaseVelocity = 0;
|
|
155
|
-
/** The sheet rests below its lowest detent, the indicator spinning above it. */
|
|
156
155
|
private refreshing = false;
|
|
157
156
|
private refreshSpin: Animation | null = null;
|
|
158
157
|
/** The sheet's top edge in the viewport. */
|
|
@@ -222,6 +221,23 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
222
221
|
this.animateToRest();
|
|
223
222
|
}
|
|
224
223
|
|
|
224
|
+
protected viewportDidReappear(firstAppearance: boolean) {
|
|
225
|
+
this.layout();
|
|
226
|
+
// An exit keeps running; a drag can't have started while hidden.
|
|
227
|
+
if (this.isDismissing) return;
|
|
228
|
+
if (firstAppearance) {
|
|
229
|
+
// Presented while hidden: nothing has been seen, so the enter plays now.
|
|
230
|
+
this.top.set(this.viewport.height);
|
|
231
|
+
this.animateIn();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
// Back on screen, e.g. navigating back to its screen: like the native
|
|
235
|
+
// sheet, it's already up, so it shows where it rests instead of
|
|
236
|
+
// transitioning there again.
|
|
237
|
+
this.top.set(this.settledTop(this.selectedIndex));
|
|
238
|
+
this.notifyPresented();
|
|
239
|
+
}
|
|
240
|
+
|
|
225
241
|
protected contentSizeDidChange() {
|
|
226
242
|
if (this.config.detents.includes('fitContent')) {
|
|
227
243
|
this.animateToRest();
|
|
@@ -245,8 +261,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
245
261
|
surface?.removeEventListener('pointerdown', this.handlePointerDown);
|
|
246
262
|
}
|
|
247
263
|
|
|
248
|
-
// Layout
|
|
249
|
-
|
|
250
264
|
private get detents(): SheetDetent[] {
|
|
251
265
|
return this.config.detents.length > 0
|
|
252
266
|
? this.config.detents
|
|
@@ -295,7 +309,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
295
309
|
return this.detents.map((_, index) => this.restingTop(index));
|
|
296
310
|
}
|
|
297
311
|
|
|
298
|
-
/** Where the sheet settles on `detents[index]`: held below the lowest detent while refreshing. */
|
|
299
312
|
private settledTop(index: number): number {
|
|
300
313
|
const top = this.restingTop(index);
|
|
301
314
|
if (!this.refreshing || Math.abs(top - Math.max(...this.detentTops)) >= 1)
|
|
@@ -365,10 +378,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
365
378
|
return { sheetTop: lowest, pull: top - lowest };
|
|
366
379
|
}
|
|
367
380
|
|
|
368
|
-
/**
|
|
369
|
-
* Centered in the gap a pull uncovers above the content, fading in as the
|
|
370
|
-
* pull nears the threshold.
|
|
371
|
-
*/
|
|
372
381
|
private renderRefreshIndicator(pull: number) {
|
|
373
382
|
const { refreshIndicator, refreshSpinner } = this.elements!;
|
|
374
383
|
const progress = Math.min(Math.max(pull / REFRESH_THRESHOLD, 0), 1);
|
|
@@ -418,8 +427,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
418
427
|
this.settle(SETTLE);
|
|
419
428
|
}
|
|
420
429
|
|
|
421
|
-
// Dragging
|
|
422
|
-
|
|
423
430
|
private canDrag(): boolean {
|
|
424
431
|
return !this.entering && !this.isDismissing && !this.isOffscreen;
|
|
425
432
|
}
|
|
@@ -687,8 +694,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
687
694
|
this.release(drag);
|
|
688
695
|
};
|
|
689
696
|
|
|
690
|
-
// Mouse and pen input.
|
|
691
|
-
|
|
692
697
|
private handlePointerDown = (event: PointerEvent) => {
|
|
693
698
|
if (
|
|
694
699
|
event.pointerType === 'touch' ||
|
package/src/web/dom.ts
CHANGED
|
@@ -17,7 +17,6 @@ export const ZERO_INSETS: Insets = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
|
17
17
|
export const canUseDOM =
|
|
18
18
|
typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
19
19
|
|
|
20
|
-
/** Width and height of the pull-to-refresh indicator. */
|
|
21
20
|
export const REFRESH_INDICATOR_SIZE = 24;
|
|
22
21
|
|
|
23
22
|
/** Converts a color from `processColor` (0xAARRGGBB) to CSS, scaling its alpha by `opacity`. */
|
|
@@ -85,7 +84,6 @@ export function readKeyboardHeight(layoutHeight: number): number {
|
|
|
85
84
|
return covered >= 1 ? Math.round(covered) : 0;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
/** The size of the viewport before anything is on screen. */
|
|
89
87
|
export function estimateViewport(): Size {
|
|
90
88
|
return {
|
|
91
89
|
width: document.documentElement.clientWidth || window.innerWidth,
|