WindowControlsOverlay: geometrychange event
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
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 methods like addEventListener(), or set an event handler property.
addEventListener("geometrychange", (event) => { })
ongeometrychange = (event) => { }
Event type
A WindowControlsOverlayGeometryChangeEvent. Inherits from Event.
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:
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
| Specification |
|---|
| Window Controls Overlay> # the-ongeometrychange-attribute> |