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

# scrollToLoadContent

Automatically scrolls through infinite scroll content by repeatedly scrolling to the bottom
until no new content loads or maximum scroll limit is reached.

```typescript theme={null}
export declare function scrollToLoadContent(input: {
  source: Page | Locator;
  onScrollProgress?: CallableFunction;
  maxScrolls?: number;
  delayInMs?: number;
  minHeightChange?: number;
}): Promise<void>;
```

## Examples

<CodeGroup>
  ```typescript Basic Infinite Scroll handling theme={null}
  import { scrollToLoadContent } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    // Scroll through entire page content
    await page.goto("https://sandbox.intuned.dev/infinite-scroll");
    await scrollToLoadContent({
      source: page,
    });
    // Will keep scrolling until the page has loaded all content or the maxScrolls is reached.
  }
  ```

  ```typescript Scroll Specific Container theme={null}
  import { scrollToLoadContent } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    // Scroll through a specific scrollable div
    await page.goto(
      "https://docs.intunedhq.com/docs/00-getting-started/introduction"
    );
    // This will scroll the sidebar content only and watch its height to change.
    const container = page.locator("xpath=//div[@id='sidebar-content']");
    await scrollToLoadContent({
      source: container,
      maxScrolls: 20,
    });
    // Will keep scrolling until the sidebar content has loaded all content or the maxScrolls is reached.
  }
  ```
</CodeGroup>

## Arguments

<ResponseField name="input" type="Object" required>
  The input object containing the data to scroll to load content.

  <Expandable title="properties" defaultOpen>
    <ResponseField name="input.source" type="Page | Locator" required>
      The Playwright Page or Locator to scroll.
    </ResponseField>

    <ResponseField name="input.onScrollProgress" type="Function">
      Optional callback function to call during each scroll iteration.
    </ResponseField>

    <ResponseField name="input.maxScrolls" type="number">
      Maximum number of scroll attempts before stopping. Defaults to 50.
    </ResponseField>

    <ResponseField name="input.delayInMs" type="number">
      Delay in milliseconds between scroll attempts. Defaults to 100.
    </ResponseField>

    <ResponseField name="input.minHeightChange" type="number">
      Minimum height change in pixels required to continue scrolling. Defaults to 100.
      If the page has loaded all content and we still haven't reached the maxScrolls, the minHeightChange will detect that no new content is loaded and stop the scrolling.
    </ResponseField>
  </Expandable>
</ResponseField>

## Returns: `Promise<void>`

Promise that resolves when scrolling is complete.
