@@ -40,19 +40,24 @@ export function usePositionFixed(options: PositionFixedOptions) {
40
40
41
41
setTimeout ( ( ) => {
42
42
requestAnimationFrame ( ( ) => {
43
+ // Attempt to check if the bottom bar appeared due to the position change
43
44
const bottomBarHeight = innerHeight - window . innerHeight
44
- if ( bottomBarHeight && scrollPos . value >= innerHeight )
45
+ if ( bottomBarHeight && scrollPos . value >= innerHeight ) {
46
+ // Move the content further up so that the bottom bar doesn't hide it
45
47
document . body . style . top = `-${ scrollPos . value + bottomBarHeight } px`
48
+ }
46
49
} )
47
50
} , 300 )
48
51
}
49
52
}
50
53
51
54
function restorePositionSetting ( ) : void {
52
55
if ( previousBodyPosition !== null ) {
56
+ // Convert the position from "px" to Int
53
57
const y = - Number . parseInt ( document . body . style . top , 10 )
54
58
const x = - Number . parseInt ( document . body . style . left , 10 )
55
59
60
+ // Restore styles
56
61
Object . assign ( document . body . style , previousBodyPosition )
57
62
58
63
requestAnimationFrame ( ( ) => {
@@ -84,10 +89,14 @@ export function usePositionFixed(options: PositionFixedOptions) {
84
89
watch ( [ isOpen , hasBeenOpened , activeUrl ] , ( ) => {
85
90
if ( nested . value || ! hasBeenOpened . value )
86
91
return
92
+
93
+ // This is needed to force Safari toolbar to show **before** the drawer starts animating to prevent a gnarly shift from happening
87
94
if ( isOpen . value ) {
88
- setPositionFixed ( )
95
+ // avoid for standalone mode (PWA)
96
+ const isStandalone = window . matchMedia ( '(display-mode: standalone)' ) . matches
97
+ ! isStandalone && setPositionFixed ( )
89
98
90
- if ( ! modal ) {
99
+ if ( ! modal . value ) {
91
100
setTimeout ( ( ) => {
92
101
restorePositionSetting ( )
93
102
} , 500 )
0 commit comments