> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# IntersectionObserver: relativeToScreen() method

APISummary
The `relativeToScreen` method can be used to specify the screen as the reference node, and the reference node's viewport can be scaled according to `margins`.

## grammar

```ts
relativeToScreen(
   margins ? margins : {left: 0, right: 0, top: 0, bottom: 0}
): IntersectionObserver;
```

### Parameters

#### margins

```ts
margins ? margins : { left: 0, right: 0, top: 0, bottom: 0 };
```

Specifies the zoom value of the reference node window. This value only affects the detection of the intersection state and does not affect the actual view display. A positive value means expanding the reference node window boundary, and a negative value means shrinking the reference node window boundary.

| Property name | Type              | Description                                                |
| ------------- | ----------------- | ---------------------------------------------------------- |
| `left`        | `number ｜ string` | The scaling value of the left boundary of the target node  |
| `right`       | `number ｜ string` | The scaling value of the right boundary of the target node |
| `top`         | `number ｜ string` | The scaling value of the upper boundary of the target node |
| `bottom`      | `number ｜ string` | The scaling value of the lower boundary of the target node |

### return value

[IntersectionObserver object](/next/api/lynx-api/intersection-observer.md).

### Precautions

The intersection state between the target node and the reference node and the target node and the ancestor node is defined as the smallest intersection ratio as follows:

- The intersection ratio of the target node and the screen (scaled by `margins`)
- The intersection ratio between the target node and `LynxView`
- The intersection ratio between the target node and the ancestor node. The ancestor node includes the nodes on the path from the target node to `LynxView`. The ancestor node will be ignored when `overflow: visible` is set.

## Compatibility

**Compatibility Table**

**Query:** `lynx-api.intersection-observer.relativeToScreen`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/intersection-observer/relativeToScreen.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| relativeToScreen | Yes (2.10) | Yes (3.4) | Yes (2.10) | Yes (3.5) | Yes (3.5) | Yes |

**`relativeToScreen`**

Specify the screen as the reference node.

