Modifiers
onGeometryChange
Calls the handler whenever the view's geometry changes, with its position and size. x and y are in the global coordinate space (relative to the window); all values are in points.
onGeometryChange(handler)
| Parameter | Type | Description |
|---|---|---|
handler | (frame: { height: number, width: number, x: number, y: number }) => void | Function called with the new frame. |
Calls the handler whenever the view's geometry changes, with its position and size. x and y are in the global coordinate space (relative to the window); all values are in points.
Returns: ModifierConfig
See: Official SwiftUI documentation.
Works with
You can add onGeometryChange to any view. It changes what you see on 33 of the 39 components.
No visible effect
These components accept it, but you see no change.
| Component | Why nothing happens |
|---|---|
| Spacer | In SDK 57, Spacer does not send modifier events to JavaScript, so the handler does not run. |
| Divider | In SDK 57, Divider does not send modifier events to JavaScript, so the handler does not run. |
| Slider | In SDK 57, Slider does not send modifier events to JavaScript, so the handler does not run. |
| Menu | In SDK 57, Menu does not send modifier events to JavaScript, so the handler does not run. |
| ContextMenu | In SDK 57, ContextMenu does not send modifier events to JavaScript, so the handler does not run. |
| AccessoryWidgetBackground | In SDK 57, AccessoryWidgetBackground does not send modifier events to JavaScript, so the handler does not run. |
Sources
The original Expo docs for this page:
- onGeometryChange (Modifiers) (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/modifiers.md)