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

# lynx: createIntersectionObserver() static method

APISummary
`lynx.createIntersectionObserver()` creates an `IntersectionObserver`. Use `options` to control when callbacks run.

## grammar

```ts
createIntersectionObserver(
  component: { componentId: string },
  options?: {
    thresholds?: number[];
    initialRatio?: number;
    observeAll?: boolean;
  },
): IntersectionObserver;
```

### Parameters

#### component

Pass `{ componentId: '' }` to find the target and reference nodes in the current `LynxView`. With a component ID, Lynx searches that component first and falls back to the whole `LynxView` if needed.

#### options

- `thresholds` is a list of intersection ratios in `[0, 1]`. The default is `[0]`. After the first check, a callback runs when the ratio reaches, leaves, or crosses a threshold.
- `initialRatio` sets the baseline for the first check. It ranges from `0` to `1` and defaults to `0`. By default, the first check triggers the callback only if the ratio is greater than `initialRatio`. When `enableIntersectionObserverInitialRatioCompatibility` is enabled (available since Lynx 4.5), the first ratio must differ from `initialRatio` and meet or exceed at least one configured threshold.
- `observeAll` is reserved on Android, iOS, and Harmony. The default is `false`.

### return value

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

## Example

This example observes how `#targetNode` intersects `#refNode` in the current `LynxView`.

```tsx
const observer = lynx.createIntersectionObserver(
  { componentId: '' },
  { thresholds: [0, 0.25, 0.5, 0.75, 1] },
);

observer.relativeTo('#refNode', { left: 10, right: 10 });
observer.observe('#targetNode', (entry) => {
  console.log(entry.intersectionRatio);
});
```

Call `observer.disconnect()` when you no longer need to observe the target.

## Compatibility

**Compatibility Table**

**Query:** `lynx-api.lynx.createIntersectionObserver`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| createIntersectionObserver | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (3.5) | Yes (3.5) | Yes |

**`createIntersectionObserver`**

Create an IntersectionObserver object.

