Window Controls Overlay API
The geometrychange event is fired when the position, size, or visibility of a Progressive Web App's title bar area changes.
This only applies to Progressive Web Apps installed on desktop operating systems and use the Window Controls Overlay API.
Syntax
Use the event name in EventTarget/addEventListener:
addEventListener("geometrychange", (event) => { })
Alternatively, assign to the event handler property of the interface:
ongeometrychange = (event) => { }
Event type
A WindowControlsOverlayGeometryChangeEvent. Inherits from Event.
WindowControlsOverlayGeometryChangeEvent
Examples
Using addEventListener():
navigator.windowControlsOverlay.addEventListener("geometrychange", (event) => {
const { x, y, width, height } = event.titlebarAreaRect;
console.log(
`The titlebar area coordinates are x:${x}, y:${y}, width:${width}, height:${height}`,
);
});
Using the ongeometrychange event handler property (but note that this replaces other event listeners added using ongeometrychange, if any):
navigator.windowControlsOverlay.ongeometrychange = (event) => {
const { x, y, width, height } = event.titlebarAreaRect;
console.log(
`The titlebar area coordinates are x:${x}, y:${y}, width:${width}, height:${height}`,
);
};
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
