You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update to the WCO docs
* Update microsoft-edge/progressive-web-apps-chromium/how-to/window-controls-overlay.md
Co-authored-by: Michael Hoffman <v-mhoffman@microsoft.com>
Co-authored-by: Michael Hoffman <v-mhoffman@microsoft.com>
Copy file name to clipboardExpand all lines: microsoft-edge/progressive-web-apps-chromium/how-to/window-controls-overlay.md
+46-64Lines changed: 46 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,15 @@ ms.author: msedgedevrel
6
6
ms.topic: conceptual
7
7
ms.prod: microsoft-edge
8
8
ms.technology: pwa
9
-
ms.date: 09/02/2021
9
+
ms.date: 09/01/2022
10
10
---
11
11
# Display content in the title bar
12
12
13
-
A PWA can define how it should be displayed on mobile platforms, by using the [display](https://developer.mozilla.org/docs/Web/Manifest/display)property in the app manifest file. However, to create an immersive, native-like experience, _desktop_ PWAs can't use this approach.
13
+
A PWA can define how it should be displayed on mobile platforms, by using the [display](https://developer.mozilla.org/docs/Web/Manifest/display)member in the web app manifest file. However, to create an immersive, native-like experience, _desktop_ PWAs can use another approach.
14
14
15
-
By default, the app area starts immediately below the reserved title bar area:
15
+
By default, a PWA installed on desktop can display content in an area that starts immediately below the reserved title bar area:
16
16
17
-

17
+

18
18
19
19
Displaying content where the title bar normally is can help PWAs feel more native. Many desktop applications, such as Visual Studio Code, Microsoft Teams, and Microsoft Edge already do this:
20
20
@@ -26,32 +26,14 @@ The Window Controls Overlay API does the following:
26
26
* Makes it possible for your content to stay clear of this overlay.

41
-
42
-
The Window Controls Overlay API is also available as an origin trials feature. For your app's users to benefit from the Window Controls Overlay without having to enable it in Microsoft Edge, you can use an origin trial.
43
-
44
-
For more information about Origin Trials, go to [Microsoft Edge Origin Trials Developer Console](https://developer.microsoft.com/microsoft-edge/origin-trials).
The first thing to do is to enable the Window Controls Overlay feature in your app's [Web App Manifest file](web-app-manifests.md). To do this, in the manifest file, set the `display_override` property:
51
33
52
34
```json
53
35
{
54
-
"display_override": ["window-controls-overlay"]
36
+
"display_override": ["window-controls-overlay"]
55
37
}
56
38
```
57
39
@@ -61,7 +43,7 @@ The first thing to do is to enable the Window Controls Overlay feature in your a
61
43
62
44
When the Window Controls Overlay feature is enabled, the user can choose to have the title bar or not, by clicking the title bar toggle button:
63
45
64
-

46
+

65
47
66
48
Your code can't assume that the window controls overlay is displayed, because:
67
49
* The user can choose whether to display the title bar.
@@ -79,56 +61,57 @@ Four environment variables are added by the Window Controls Overlay feature:
79
61
80
62
| Variable | Description |
81
63
|:--- |:---
82
-
|`titlebar-area-x`| Distance, in `px`, of the overlay from the left side of the window |
83
-
|`titlebar-area-y`| Distance, in `px`, of the overlay from the top side of the window |
84
-
|`titlebar-area-width`| Width of the overlay, in `px`|
85
-
|`titlebar-area-height`| Height of the overlay, in `px`|
64
+
|`titlebar-area-x`| Distance, in `px`, of the area normally occupied by the title bar from the left side of the window |
65
+
|`titlebar-area-y`| Distance, in `px`, of the area normally occupied by the title bar from the top side of the window |
66
+
|`titlebar-area-width`| Width of the title bar area, in `px`|
67
+
|`titlebar-area-height`| Height of the title bar area, in `px`|
86
68
87
-
You can use these environment variables to position and size your app's title bar:
69
+
You can use these environment variables to position and size your own content where the title bar would normally appear, when the window controls overlay feature is disabled:
88
70
89
71
```css
90
72
#title-bar {
91
-
position: fixed;
92
-
left: env(titlebar-area-x);
93
-
top: env(titlebar-area-y);
94
-
height: env(titlebar-area-height);
95
-
width: env(titlebar-area-width);
73
+
position: fixed;
74
+
left: env(titlebar-area-x, 0);
75
+
top: env(titlebar-area-y, 0);
76
+
height: env(titlebar-area-height, 50px);
77
+
width: env(titlebar-area-width, 100%);
96
78
}
97
79
```
98
80
99
81
Using `position: fixed;` makes sure your title bar does not scroll with the rest of the content and instead stays aligned with the window controls overlay.
100
82
101
83
Knowing where the overlay is and how big it is is important. The overlay might not always be on the same side of the window; on macOS, the overlay is on the left side, but on Windows, the overlay is on the right side. Also, the overlay might not always be the same size.
102
84
85
+
The `env()` CSS function takes a second parameter that's useful for defining the position of your app content when the window controls overlay feature is missing or disabled.
## Make regions of your app drag handlers for the window
106
90
107
-
When the title bar is hidden, only the system-critical window controls remain visible (the **Maximize**, **Minimize**, **Close**, and **App Info** icons). This means that there is very little space available for users to move the app around.
91
+
When the title bar is hidden, only the system-critical window controls remain visible (the **Maximize**, **Minimize**, **Close**, and **App Info** icons). This means that there is very little space available for users to move the application window around.
108
92
109
93
You can use the `-webkit-app-region` CSS property to offer more ways for users to drag the app. For example, if your app has its own titlebar, you can turn its titlebar into a window drag handler:
A user can toggle the title bar or change the window dimensions while the app is running. Knowing when these things happen can be important for your app. Your app might need to rearrange some of the content that's displayed in the title bar, or rearrange your layout elsewhere on the page.
110
+
A user can toggle the title bar or change the window dimensions while the app is running. Knowing when these things happen can be important for your app. Your app might need to rearrange some of the content that's displayed in the title bar, or rearrange the layout elsewhere on the page.
127
111
128
-
To listen for changes, use the `geometrychange` event. To detect whether the title bar is visible, use the `visible` property on the `navigator.windowControlsOverlay` object.
112
+
To listen for changes, use the `geometrychange` event on the `navigator.windowControlsOverlay` object. To detect whether the title bar is visible, use the `visible` property on the `navigator.windowControlsOverlay` object.
129
113
130
-
> [!NOTE]
131
-
> The `geometrychange` is fired very frequently when the user resizes the window. To avoid running layout-changing code too often and causing performance problems in your app, use a `debounce` function to limit how many times the event is handled. See [The Difference Between Throttling and Debouncing](https://css-tricks.com/the-difference-between-throttling-and-debouncing/).
114
+
Note that the `geometrychange` is fired very frequently when the user resizes the window. To avoid running layout-changing code too often and causing performance problems in your app, use a `debounce` function to limit how many times the event is handled. See [The Difference Between Throttling and Debouncing](https://css-tricks.com/the-difference-between-throttling-and-debouncing/).
My Tracks is a PWA demo app that uses the Window Controls Overlay feature.
163
-
164
-
1. In Microsoft Edge, [Enable the Window Controls Overlay](#enable-the-window-controls-overlay-in-your-app).
146
+
1DIV is a PWA demo app that uses the Window Controls Overlay feature.
165
147
166
-
2. Go to [My Tracks](https://captainbrosset.github.io/mytracks/) and install the app.
148
+
1. In Microsoft Edge, go to [1DIV](https://microsoftedge.github.io/Demos/1DIV/dist/) and install the app.
167
149
168
-
3. Select the **Hide title bar**button from the app title bar.
150
+
1. Click **Hide title bar**in the app title bar.
169
151
170
-
The app now displays content all the way to the top of the window frame, where the title bar used to be. The top area of the map is a drag handler, to let the user move the window.
152
+
The app now displays content all the way to the top of the window frame, where the title bar used to be. The top area of the app is a drag handler, to let users move the window.
171
153
172
-

154
+

173
155
174
-
The source code for this app is in the [My Tracks](https://github.com/captainbrosset/mytracks) repo.
156
+
The source code for this demo app is in the [1DIV](https://github.com/MicrosoftEdge/Demos/tree/main/1DIV) repo.
175
157
176
-
* The [manifest.json](https://github.com/captainbrosset/mytracks/blob/main/mytracks/manifest.json) source file declares the app's use of the Window Controls Overlay feature.
158
+
* The [manifest.json](https://github.com/MicrosoftEdge/Demos/blob/main/1DIV/dist/manifest.json) source file declares the app's use of the Window Controls Overlay feature.
177
159
178
-
* The [overlay.js](https://github.com/captainbrosset/mytracks/blob/main/src/overlay.js) source file uses the `navigator.windowControlsOverlay` object.
160
+
* The [app.js](https://github.com/MicrosoftEdge/Demos/blob/main/1DIV/src/app.js) source file uses the `navigator.windowControlsOverlay` object.
179
161
180
-
* The [style.css](https://github.com/captainbrosset/mytracks/blob/main/mytracks/style.css) source file uses the `titlebar-area-height` CSS environment variable.
162
+
* The [app.css](https://github.com/MicrosoftEdge/Demos/blob/main/1DIV/dist/app.css) source file uses the `titlebar-area-*` CSS environment variables.
0 commit comments