Skip to content

UIWindowSceneGeometryChangeEvent ​

UIWindowSceneGeometryChangeEvent represents a change in a scene's geometry, for example the phone being rotated.

The geometrychange event of UIWindowScene is this class. It carries the interface orientation from before the change; read the current one from the scene's effectiveGeometry.

Inheritance: Event → UIWindowSceneGeometryChangeEvent

Constructor ​

UIWindowSceneGeometryChangeEvent()

Creates a UIWindowSceneGeometryChangeEvent. The runtime creates one itself when it fires the events below; app code can use it to build an event object and fire it with dispatchEvent() to try out a listener.

Instance properties ​

Also inherits the properties of Event; the most commonly used are type and target. The properties below are read-only; assigning to them throws TypeError.

PropertyDescription
previousInterfaceOrientation read-onlyThe interface orientation before the change

These properties live on the prototype, not on the event object itself: Object.keys(event) and { ...event } don't include them, so read them one by one. See Events with fields.

Events that use this class ​

ObjectEvents
UIWindowScenegeometrychange

It can't be canceled: cancelable is false, and preventDefault() has no effect.

Examples ​

js
application.addEventListener('sceneconnect', (e) => {
  e.scene.addEventListener('geometrychange', (change) => {
    console.log(change instanceof UIWindowSceneGeometryChangeEvent, change.previousInterfaceOrientation);
  });
});

Effect: when the phone rotates, prints true and the orientation from before.

Corresponding iOS API ​

ObjCJS
windowScene:didUpdateEffectiveGeometry:The geometrychange event
previousEffectiveGeometry.interfaceOrientationevent.previousInterfaceOrientation

See also ​