> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# my.getScreenOrientation

> Get the current screen orientation.

Use this API to get the current screen orientation of the device.

## Parameters

| Property | Type     | Required | Description                   |
| -------- | -------- | -------- | ----------------------------- |
| success  | Function | No       | Callback on success           |
| fail     | Function | No       | Callback on failure           |
| complete | Function | No       | Callback that always executes |

## Success Callback Parameters

| Property    | Type    | Description                                                                                 |
| ----------- | ------- | ------------------------------------------------------------------------------------------- |
| success     | Boolean | Specifies whether the call is successful. When the value is `true`, the call is successful. |
| orientation | String  | Indicates the orientation of the screen, `portrait` or `landscape`.                         |

## Code Example

### Basic Usage

```javascript theme={null}
my.getScreenOrientation({
  success(res) {
    console.log('Current orientation:', res.orientation);
  }
});
```

### Adaptive Layout

```javascript theme={null}
Page({
  data: {
    isLandscape: false
  },

  onLoad() {
    this.checkOrientation();
    my.onScreenOrientationChange(this.handleOrientationChange);
  },

  checkOrientation() {
    my.getScreenOrientation({
      success: (res) => {
        const isLandscape = res.orientation.includes('landscape');
        this.setData({ isLandscape });
      }
    });
  },

  handleOrientationChange(res) {
    const isLandscape = res.orientation.includes('landscape');
    this.setData({ isLandscape });
  },

  onUnload() {
    my.offScreenOrientationChange(this.handleOrientationChange);
  }
});
```

## Orientation Values

| Value       | Description          |
| ----------- | -------------------- |
| `portrait`  | Device held upright  |
| `landscape` | Device held sideways |

## Related APIs

<CardGroup cols={2}>
  <Card title="my.setScreenOrientation" icon="rotate" href="/jsapi/device/screen-orientation/my.setScreenOrientation">
    Set screen orientation
  </Card>

  <Card title="my.onScreenOrientationChange" icon="mobile" href="/jsapi/device/screen-orientation/my.onScreenOrientationChange">
    Listen for orientation changes
  </Card>
</CardGroup>
