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

# `<scroll-coordinator>`

APISummary
`<scroll-coordinator>` is a nested scroll coordination component for implementing coordinated scrolling between multiple scrollable containers. It is commonly used in sticky-header page layouts found in mainstream apps, and is typically combined with `<viewpager>` and `<list>` to build composite scenarios involving nested scrolling and tabbed paging.

:::info
`<scroll-coordinator>` coordinates nested structures through `<scroll-coordinator-header>` and `<scroll-coordinator-slot>`, achieving the following behavior:

- When the outer layer scrolls to the bottom, scroll control is automatically handed over to the inner layer
- When the inner layer scrolls to the top, scroll control is automatically returned to the outer layer
- The handover of scroll control is smooth and seamless

```tsx
// ❌ Not supported: directly nesting scrollable containers
<scroll-view id="outer">
  <list id="inner" />
</scroll-view>

// ✅ Supported: using scroll-coordinator for coordinated nested scrolling
<scroll-coordinator>
  <scroll-coordinator-header id="outer" />
  <scroll-coordinator-slot>
    <list id="inner" />
  </scroll-coordinator-slot>
</scroll-coordinator>
```

:::

## Usage

The core layout requirement of `<scroll-coordinator>` is to control via CSS: **`scroll-coordinator` height == `scroll-coordinator-slot` height + toolbar height**.

### Layout Guidelines

- `<scroll-coordinator>`: vertical flex layout, **`display: flex; flex-direction: column;`**
- `<scroll-coordinator-header>`: out of normal flow, **`position: absolute;`**
- `<scroll-coordinator-toolbar>`: participates in layout, **`display: flex;`**
- `<scroll-coordinator-slot>`: fills remaining space, **`flex: 1;`**

```css
.coordinator {
  width: 100%;
  height: 100%
  display: flex;
  flex-direction: column;
}

.coordinator-toolbar {
  display: flex;
  width: 100%;
}

.coordinator-header {
  position: absolute;
  width: 100%;
}

.coordinator-slot {
  width: 100%;
  flex-direction: column;
  flex: 1;
}
```

### Vertical Coordinated Scrolling

> A `<list>` must be placed inside `<scroll-coordinator-slot>` to enable vertical coordinated scrolling
>
> ```tsx
> <scroll-coordinator class="coordinator">
>   <scroll-coordinator-header class="coordinator-header">
>     <Header />
>   </scroll-coordinator-header>
>   <scroll-coordinator-slot class="coordinator-slot">
>     <list />
>   </scroll-coordinator-slot>
> </scroll-coordinator>
> ```

**This is an example below: scroll-coordinator**

**Bundle:** `dist/base.lynx.bundle`

```tsx
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root } from "@lynx-js/react";

import image0 from "../assets/item_0.jpg";
import image1 from "../assets/item_1.jpg";
import image2 from "../assets/item_2.jpg";

const App = () => {
  const coverImages = [image0, image1, image2];
  const tabs = ["Featured", "Nearby", "Saved"];
  const listItems = Array.from({ length: 24 }, (_, index) => {
    return {
      image: coverImages[index % coverImages.length],
      title: `Scenic stop ${index + 1}`,
      subtitle: index % 2 === 0 ? "Quiet path with a wide lookout" : "Short trail near the water",
      tag: index % 3 === 0 ? "Fresh" : (index % 3 === 1 ? "Calm" : "Open"),
    };
  });

  return (
    <view
      style={{
        width: "100%",
        height: "100%",
        flexDirection: "column",
        display: "flex",
        padding: "24px",
        backgroundColor: "#F6F7F9",
        boxSizing: "border-box",
      }}
    >
      <text style={{ fontSize: "32px", fontWeight: "700", color: "#202124" }}>Scroll Coordinator</text>
      <scroll-coordinator
        style={{
          marginTop: "24px",
          width: "100%",
          height: "100%",
          flex: "1",
          display: "flex",
          flexDirection: "column",
          position: "relative",
          overflow: "hidden",
          backgroundColor: "#EDEFF2",
        }}
      >
        {
          /*
          Optional, fixed at the top of the scroll coordinator and won't collapse.
          When it exists, control scroll-coordinator.height == slot.height + toolbar.height through CSS.
          */
        }
        <scroll-coordinator-toolbar
          style={{
            display: "flex",
            width: "100%",
            height: "88rpx",
            alignItems: "center",
            justifyContent: "space-between",
            padding: "0 24rpx",
            backgroundColor: "#FFFFFFAA",
            boxSizing: "border-box",
          }}
        >
          <text style={{ fontSize: "26rpx", fontWeight: "700", color: "#202124" }}>Weekend Routes</text>
          <text style={{ fontSize: "22rpx", color: "#2D7D46" }}>3 picks</text>
        </scroll-coordinator-toolbar>

        {
          /*
          Required, it can be scrolled in scroll coordinator without affecting the layout,
          so it is recommended to set position: absolute.
          No need to place scroll-view or list inside.
        */
        }
        <scroll-coordinator-header
          style={{
            position: "absolute",
            width: "100%",
            height: "360rpx",
          }}
        >
          <view
            style={{
              width: "100%",
              height: "360rpx",
              overflow: "hidden",
            }}
          >
            <image
              mode="aspectFill"
              src={image0}
              style={{
                width: "100%",
                height: "360rpx",
              }}
            />
            <view
              style={{
                position: "absolute",
                left: "0",
                bottom: "0",
                width: "100%",
                padding: "24rpx",
                backgroundColor: "#00000066",
                boxSizing: "border-box",
              }}
            >
              <text style={{ fontSize: "34rpx", fontWeight: "700", color: "#FFFFFF" }}>Forest Ridge</text>
              <text style={{ marginTop: "8rpx", fontSize: "22rpx", color: "#FFFFFF" }}>
                Sunrise views, shaded paths, and easy waypoints.
              </text>
            </view>
          </view>
        </scroll-coordinator-header>

        {
          /*
          Required, its size must be the same as scroll coordinator's size.
          If there is a toolbar, subtract its height.
          After the header is completely collapsed, the slot will occupy the entire scroll coordinator viewport.
          In its child nodes, scrolling can be achieved and can continue after the header is collapsed.
          When placing scroll-view, add enable-new-nested on scroll-view to support nested scrolling interactions.
        */
        }
        <scroll-coordinator-slot
          style={{
            width: "100%",
            flexDirection: "column",
            flex: "1",
            display: "flex",
          }}
        >
          {
            /*
            Optional sticky area. When the header is completely collapsed, it will stay at the top of the slot.
            You can place Tabs modules or any other content here.
            By default it accepts up and down dragging gestures. Use enable-drag to control it.
          */
          }
          <scroll-coordinator-slot-drag style={{ width: "100%" }}>
            <view
              style={{
                width: "100%",
                height: "96rpx",
                display: "flex",
                flexDirection: "row",
                alignItems: "center",
                padding: "0 16rpx",
                backgroundColor: "#FFFFFF",
                boxSizing: "border-box",
              }}
            >
              {tabs.map((tab, index) => {
                return (
                  <view
                    style={{
                      height: "56rpx",
                      padding: "0 20rpx",
                      marginRight: "12rpx",
                      justifyContent: "center",
                      borderRadius: "8px",
                      backgroundColor: index === 0 ? "#DDF3E5" : "#EEF1F4",
                    }}
                  >
                    <text style={{ fontSize: "22rpx", color: index === 0 ? "#1F7A4D" : "#4E5969" }}>{tab}</text>
                  </view>
                );
              })}
            </view>
          </scroll-coordinator-slot-drag>
          <list
            scroll-orientation="vertical"
            list-type="single"
            span-count={1}
            style={{
              width: "100%",
              height: "100%",
              flex: "1",
              listMainAxisGap: "12px",
              padding: "12px",
              boxSizing: "border-box",
            }}
          >
            {listItems.map((item) => {
              return (
                <list-item
                  item-key={item.title}
                  key={item.title}
                >
                  <view
                    style={{
                      width: "100%",
                      height: "144rpx",
                      display: "flex",
                      flexDirection: "row",
                      alignItems: "center",
                      padding: "12rpx",
                      borderRadius: "8px",
                      backgroundColor: "#FFFFFF",
                      boxSizing: "border-box",
                    }}
                  >
                    <image
                      mode="aspectFill"
                      src={item.image}
                      style={{
                        width: "120rpx",
                        height: "120rpx",
                        borderRadius: "8px",
                      }}
                    />
                    <view
                      style={{
                        marginLeft: "18rpx",
                        flex: 1,
                        flexDirection: "column",
                      }}
                    >
                      <text style={{ fontSize: "28rpx", fontWeight: "700", color: "#202124" }}>{item.title}</text>
                      <text style={{ marginTop: "8rpx", fontSize: "22rpx", color: "#5F6673" }}>{item.subtitle}</text>
                      <text style={{ marginTop: "10rpx", fontSize: "20rpx", color: "#2D7D46" }}>{item.tag}</text>
                    </view>
                  </view>
                </list-item>
              );
            })}
          </list>
        </scroll-coordinator-slot>
      </scroll-coordinator>
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.1



### Horizontal Paged Scrolling

> `<scroll-coordinator-slot>` can detect `<viewpager>` page switch events and re-bind the nested scroll relationship with the `<list>` inside.
>
> ```tsx
> <scroll-coordinator class="coordinator">
>   <scroll-coordinator-header class="coordinator-header">
>     <Header />
>   </scroll-coordinator-header>
>   <scroll-coordinator-slot class="coordinator-slot">
>     <Tabs />
>     <viewpager>
>       <viewpager-item>
>         <list />
>       </viewpager-item>
>     </viewpager>
>   </scroll-coordinator-slot>
> </scroll-coordinator>
> ```

**This is an example below: scroll-coordinator**

**Bundle:** `dist/base.lynx.bundle`

```tsx
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root, useState } from "@lynx-js/react";

import image0 from "../assets/item_0.jpg";
import image1 from "../assets/item_1.jpg";
import image2 from "../assets/item_2.jpg";

const App = () => {
  const [currentPage, setCurrentPage] = useState(0);
  const coverImages = [image0, image1, image2];
  const tabs = ["Featured", "Nearby", "Saved"];
  const listPages = ["A", "B", "C"];
  const listItems = Array.from({ length: 24 }, (_, index) => {
    return {
      image: coverImages[index % coverImages.length],
      title: `Scenic stop ${index + 1}`,
      subtitle: index % 2 === 0 ? "Quiet path with a wide lookout" : "Short trail near the water",
      tag: index % 3 === 0 ? "Fresh" : (index % 3 === 1 ? "Calm" : "Open"),
    };
  });

  return (
    <view
      style={{
        width: "100%",
        height: "100%",
        flexDirection: "column",
        display: "flex",
        padding: "24px",
        backgroundColor: "#F6F7F9",
        boxSizing: "border-box",
      }}
    >
      <text style={{ fontSize: "32px", fontWeight: "700", color: "#202124" }}>Scroll Coordinator</text>
      <scroll-coordinator
        style={{
          marginTop: "24px",
          width: "100%",
          height: "100%",
          flex: "1",
          display: "flex",
          flexDirection: "column",
          position: "relative",
          overflow: "hidden",
          backgroundColor: "#EDEFF2",
        }}
      >
        {
          /*
          Optional, fixed at the top of the scroll coordinator and won't collapse.
          When it exists, control scroll-coordinator.height == slot.height + toolbar.height through CSS.
          */
        }
        <scroll-coordinator-toolbar
          style={{
            display: "flex",
            width: "100%",
            height: "88rpx",
            alignItems: "center",
            justifyContent: "space-between",
            padding: "0 24rpx",
            backgroundColor: "#FFFFFFAA",
            boxSizing: "border-box",
          }}
        >
          <text style={{ fontSize: "26rpx", fontWeight: "700", color: "#202124" }}>Weekend Routes</text>
          <text style={{ fontSize: "22rpx", color: "#2D7D46" }}>3 lists</text>
        </scroll-coordinator-toolbar>

        {
          /*
          Required, it can be scrolled in scroll coordinator without affecting the layout,
          so it is recommended to set position: absolute.
          No need to place scroll-view or list inside.
        */
        }
        <scroll-coordinator-header
          style={{
            position: "absolute",
            width: "100%",
            height: "360rpx",
          }}
        >
          <view
            style={{
              width: "100%",
              height: "360rpx",
              overflow: "hidden",
            }}
          >
            <image
              mode="aspectFill"
              src={image0}
              style={{
                width: "100%",
                height: "360rpx",
              }}
            />
            <view
              style={{
                position: "absolute",
                left: "0",
                bottom: "0",
                width: "100%",
                padding: "24rpx",
                backgroundColor: "#00000066",
                boxSizing: "border-box",
              }}
            >
              <text style={{ fontSize: "34rpx", fontWeight: "700", color: "#FFFFFF" }}>Forest Ridge</text>
              <text style={{ marginTop: "8rpx", fontSize: "22rpx", color: "#FFFFFF" }}>
                Sunrise views, shaded paths, and easy waypoints.
              </text>
            </view>
          </view>
        </scroll-coordinator-header>

        {
          /*
          Required, its size must be the same as scroll coordinator's size.
          If there is a toolbar, subtract its height.
          After the header is completely collapsed, the slot will occupy the entire scroll coordinator viewport.
          In its child nodes, scrolling can be achieved and can continue after the header is collapsed.
          When placing scroll-view, add enable-new-nested on scroll-view to support nested scrolling interactions.
        */
        }
        <scroll-coordinator-slot
          style={{
            width: "100%",
            flexDirection: "column",
            flex: "1",
            display: "flex",
          }}
        >
          {
            /*
            Optional sticky area. When the header is completely collapsed, it will stay at the top of the slot.
            You can place Tabs modules or any other content here.
            By default it accepts up and down dragging gestures. Use enable-drag to control it.
          */
          }
          <scroll-coordinator-slot-drag style={{ width: "100%" }}>
            <view
              style={{
                width: "100%",
                height: "96rpx",
                display: "flex",
                flexDirection: "row",
                alignItems: "center",
                padding: "0 16rpx",
                backgroundColor: "#FFFFFF",
                boxSizing: "border-box",
              }}
            >
              {tabs.map((tab, index) => {
                const selected = currentPage === index;

                return (
                  <view
                    style={{
                      height: "56rpx",
                      padding: "0 20rpx",
                      marginRight: "12rpx",
                      justifyContent: "center",
                      borderRadius: "8px",
                      backgroundColor: selected ? "#DDF3E5" : "#EEF1F4",
                    }}
                  >
                    <text
                      style={{
                        fontSize: "22rpx",
                        fontWeight: selected ? "700" : "400",
                        color: selected ? "#1F7A4D" : "#4E5969",
                      }}
                    >
                      {tab}
                    </text>
                  </view>
                );
              })}
            </view>
          </scroll-coordinator-slot-drag>
          <viewpager
            style={{
              width: "100%",
              height: "100%",
              flex: "1",
              display: "flex",
              flexDirection: "row",
            }}
            bindwillchange={(e) => {
              setCurrentPage(e.detail.index);
            }}
          >
            {listPages.map((page) => {
              return (
                <viewpager-item
                  style={{
                    width: "100%",
                    height: "100%",
                    flexShrink: 0,
                  }}
                >
                  <list
                    scroll-orientation="vertical"
                    list-type="single"
                    span-count={1}
                    style={{
                      width: "100%",
                      height: "100%",
                      listMainAxisGap: "12px",
                      padding: "12px",
                      boxSizing: "border-box",
                    }}
                  >
                    {listItems.map((item, index) => {
                      return (
                        <list-item
                          item-key={`list-${page}-item-${index}`}
                          key={`list-${page}-item-${index}`}
                        >
                          <view
                            style={{
                              width: "100%",
                              height: "144rpx",
                              display: "flex",
                              flexDirection: "row",
                              alignItems: "center",
                              padding: "12rpx",
                              borderRadius: "8px",
                              backgroundColor: "#FFFFFF",
                              boxSizing: "border-box",
                            }}
                          >
                            <image
                              mode="aspectFill"
                              src={item.image}
                              style={{
                                width: "120rpx",
                                height: "120rpx",
                                borderRadius: "8px",
                              }}
                            />
                            <view
                              style={{
                                marginLeft: "18rpx",
                                flex: 1,
                                flexDirection: "column",
                              }}
                            >
                              <text style={{ fontSize: "28rpx", fontWeight: "700", color: "#202124" }}>
                                {`${item.title} ${page}`}
                              </text>
                              <text style={{ marginTop: "8rpx", fontSize: "22rpx", color: "#5F6673" }}>
                                {item.subtitle}
                              </text>
                              <text style={{ marginTop: "10rpx", fontSize: "20rpx", color: "#2D7D46" }}>
                                {item.tag}
                              </text>
                            </view>
                          </view>
                        </list-item>
                      );
                    })}
                  </list>
                </viewpager-item>
              );
            })}
          </viewpager>
        </scroll-coordinator-slot>
      </scroll-coordinator>
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.1



### Full-Page Pull-to-Refresh

> Wrap `<scroll-coordinator>` with `<refresh>` and set `refresh-mode="fold" bounces={true}` to enable full-page pull-to-refresh
>
> ```tsx
> <refresh>
>   <refresh-header>
>     <Loading />
>   </refresh-header>
>   <scroll-coordinator class="coordinator" bounces={true} refresh-mode="fold">
>     <scroll-coordinator-header class="coordinator-header">
>       <Header />
>     </scroll-coordinator-header>
>     <scroll-coordinator-slot class="coordinator-slot">
>       <viewpager>
>         <viewpager-item>
>           <list />
>         </viewpager-item>
>       </viewpager>
>     </scroll-coordinator-slot>
>   </scroll-coordinator>
> </refresh>
> ```

**This is an example below: scroll-coordinator**

**Bundle:** `dist/base.lynx.bundle`

```tsx
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root, useRef, useState } from "@lynx-js/react";
import type { NodesRef } from "@lynx-js/types";

import loadingGif from "../assets/bg_flower.gif";
import image0 from "../assets/item_0.jpg";
import image1 from "../assets/item_1.jpg";
import image2 from "../assets/item_2.jpg";

const App = () => {
  const refreshRef = useRef<NodesRef>(null);
  const [currentPage, setCurrentPage] = useState(0);
  const coverImages = [image0, image1, image2];
  const tabs = ["Featured", "Nearby", "Saved"];
  const listPages = ["A", "B", "C"];
  const listItems = Array.from({ length: 24 }, (_, index) => {
    return {
      image: coverImages[index % coverImages.length],
      title: `Scenic stop ${index + 1}`,
      subtitle: index % 2 === 0 ? "Quiet path with a wide lookout" : "Short trail near the water",
      tag: index % 3 === 0 ? "Fresh" : (index % 3 === 1 ? "Calm" : "Open"),
    };
  });

  const onStartRefresh = () => {
    setTimeout(() => {
      refreshRef.current?.invoke({
        method: "finishRefresh",
      }).exec();
    }, 2000);
  };

  return (
    <view
      style={{
        width: "100%",
        height: "100%",
        flexDirection: "column",
        display: "flex",
        padding: "24px",
        backgroundColor: "#F6F7F9",
        boxSizing: "border-box",
      }}
    >
      <text style={{ fontSize: "32px", fontWeight: "700", color: "#202124" }}>Scroll Coordinator</text>
      <refresh
        ref={refreshRef}
        bindstartrefresh={onStartRefresh}
        style={{
          marginTop: "24px",
          width: "100%",
          height: "100%",
          flex: "1",
        }}
      >
        <refresh-header
          style={{
            width: "100%",
            height: "104rpx",
            position: "absolute",
            justifyContent: "center",
            alignItems: "center",
            backgroundColor: "#F6F7F9",
          }}
        >
          <image
            mode="aspectFit"
            src={loadingGif}
            style={{
              width: "48rpx",
              height: "48rpx",
            }}
          />
          <text style={{ marginTop: "8rpx", fontSize: "20rpx", color: "#4E5969" }}>Refreshing routes...</text>
        </refresh-header>
        <scroll-coordinator
          refresh-mode="fold"
          style={{
            width: "100%",
            height: "100%",
            flex: "1",
            display: "flex",
            flexDirection: "column",
            position: "relative",
            overflow: "hidden",
            backgroundColor: "#EDEFF2",
          }}
        >
          {
            /*
          Required, it can be scrolled in scroll coordinator without affecting the layout,
          so it is recommended to set position: absolute.
          No need to place scroll-view or list inside.
        */
          }
          <scroll-coordinator-header
            style={{
              position: "absolute",
              width: "100%",
              height: "360rpx",
            }}
          >
            <view
              style={{
                width: "100%",
                height: "360rpx",
                overflow: "hidden",
              }}
            >
              <image
                mode="aspectFill"
                src={image0}
                style={{
                  width: "100%",
                  height: "360rpx",
                }}
              />
              <view
                style={{
                  position: "absolute",
                  left: "0",
                  bottom: "0",
                  width: "100%",
                  padding: "24rpx",
                  backgroundColor: "#00000066",
                  boxSizing: "border-box",
                }}
              >
                <text style={{ fontSize: "34rpx", fontWeight: "700", color: "#FFFFFF" }}>Forest Ridge</text>
                <text style={{ marginTop: "8rpx", fontSize: "22rpx", color: "#FFFFFF" }}>
                  Sunrise views, shaded paths, and easy waypoints.
                </text>
              </view>
            </view>
          </scroll-coordinator-header>

          {
            /*
          Required, its size must be the same as scroll coordinator's size.
          If there is a toolbar, subtract its height.
          After the header is completely collapsed, the slot will occupy the entire scroll coordinator viewport.
          In its child nodes, scrolling can be achieved and can continue after the header is collapsed.
          When placing scroll-view, add enable-new-nested on scroll-view to support nested scrolling interactions.
        */
          }
          <scroll-coordinator-slot
            style={{
              width: "100%",
              flexDirection: "column",
              flex: "1",
              display: "flex",
            }}
          >
            {
              /*
            Optional sticky area. When the header is completely collapsed, it will stay at the top of the slot.
            You can place Tabs modules or any other content here.
            By default it accepts up and down dragging gestures. Use enable-drag to control it.
          */
            }
            <scroll-coordinator-slot-drag style={{ width: "100%" }}>
              <view
                style={{
                  width: "100%",
                  height: "96rpx",
                  display: "flex",
                  flexDirection: "row",
                  alignItems: "center",
                  padding: "0 16rpx",
                  backgroundColor: "#FFFFFF",
                  boxSizing: "border-box",
                }}
              >
                {tabs.map((tab, index) => {
                  const selected = currentPage === index;

                  return (
                    <view
                      style={{
                        height: "56rpx",
                        padding: "0 20rpx",
                        marginRight: "12rpx",
                        justifyContent: "center",
                        borderRadius: "8px",
                        backgroundColor: selected ? "#DDF3E5" : "#EEF1F4",
                      }}
                    >
                      <text
                        style={{
                          fontSize: "22rpx",
                          fontWeight: selected ? "700" : "400",
                          color: selected ? "#1F7A4D" : "#4E5969",
                        }}
                      >
                        {tab}
                      </text>
                    </view>
                  );
                })}
              </view>
            </scroll-coordinator-slot-drag>
            <viewpager
              style={{
                width: "100%",
                height: "100%",
                flex: "1",
                display: "flex",
                flexDirection: "row",
              }}
              bindwillchange={(e) => {
                setCurrentPage(e.detail.index);
              }}
            >
              {listPages.map((page) => {
                return (
                  <viewpager-item
                    style={{
                      width: "100%",
                      height: "100%",
                      flexShrink: 0,
                    }}
                  >
                    <list
                      scroll-orientation="vertical"
                      list-type="single"
                      span-count={1}
                      style={{
                        width: "100%",
                        height: "100%",
                        listMainAxisGap: "12px",
                        padding: "12px",
                        boxSizing: "border-box",
                      }}
                    >
                      {listItems.map((item, index) => {
                        return (
                          <list-item
                            item-key={`list-${page}-item-${index}`}
                            key={`list-${page}-item-${index}`}
                          >
                            <view
                              style={{
                                width: "100%",
                                height: "144rpx",
                                display: "flex",
                                flexDirection: "row",
                                alignItems: "center",
                                padding: "12rpx",
                                borderRadius: "8px",
                                backgroundColor: "#FFFFFF",
                                boxSizing: "border-box",
                              }}
                            >
                              <image
                                mode="aspectFill"
                                src={item.image}
                                style={{
                                  width: "120rpx",
                                  height: "120rpx",
                                  borderRadius: "8px",
                                }}
                              />
                              <view
                                style={{
                                  marginLeft: "18rpx",
                                  flex: 1,
                                  flexDirection: "column",
                                }}
                              >
                                <text style={{ fontSize: "28rpx", fontWeight: "700", color: "#202124" }}>
                                  {`${item.title} ${page}`}
                                </text>
                                <text style={{ marginTop: "8rpx", fontSize: "22rpx", color: "#5F6673" }}>
                                  {item.subtitle}
                                </text>
                                <text style={{ marginTop: "10rpx", fontSize: "20rpx", color: "#2D7D46" }}>
                                  {item.tag}
                                </text>
                              </view>
                            </view>
                          </list-item>
                        );
                      })}
                    </list>
                  </viewpager-item>
                );
              })}
            </viewpager>
          </scroll-coordinator-slot>
        </scroll-coordinator>
      </refresh>
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.1



### Per-Tab Pull-to-Refresh

> Wrap the `<list>` inside `<scroll-coordinator-slot>` with `<refresh>` and set `refresh-mode="page" bounces={false}` to enable per-tab pull-to-refresh
>
> ```tsx
> <scroll-coordinator class="coordinator" bounces={false} refresh-mode="page">
>   <scroll-coordinator-header class="coordinator-header">
>     <Header />
>   </scroll-coordinator-header>
>   <scroll-coordinator-slot class="coordinator-slot">
>     <viewpager>
>       <viewpager-item>
>         <refresh>
>           <refresh-header />
>           <list />
>         </refresh>
>       </viewpager-item>
>     </viewpager>
>   </scroll-coordinator-slot>
> </scroll-coordinator>
> ```

**This is an example below: scroll-coordinator**

**Bundle:** `dist/base.lynx.bundle`

```tsx
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root, useRef, useState } from "@lynx-js/react";
import type { NodesRef } from "@lynx-js/types";

import loadingGif from "../assets/bg_flower.gif";
import image0 from "../assets/item_0.jpg";
import image1 from "../assets/item_1.jpg";
import image2 from "../assets/item_2.jpg";

const App = () => {
  const refreshRefs = useRef<Record<string, NodesRef | null>>({});
  const [currentPage, setCurrentPage] = useState(0);
  const coverImages = [image0, image1, image2];
  const tabs = ["Featured", "Nearby", "Saved"];
  const listPages = ["A", "B", "C"];
  const listItems = Array.from({ length: 24 }, (_, index) => {
    return {
      image: coverImages[index % coverImages.length],
      title: `Scenic stop ${index + 1}`,
      subtitle: index % 2 === 0 ? "Quiet path with a wide lookout" : "Short trail near the water",
      tag: index % 3 === 0 ? "Fresh" : (index % 3 === 1 ? "Calm" : "Open"),
    };
  });

  const onStartRefresh = (page: string) => {
    setTimeout(() => {
      refreshRefs.current[page]?.invoke({
        method: "finishRefresh",
      }).exec();
    }, 2000);
  };

  return (
    <view
      style={{
        width: "100%",
        height: "100%",
        flexDirection: "column",
        display: "flex",
        padding: "24px",
        backgroundColor: "#F6F7F9",
        boxSizing: "border-box",
      }}
    >
      <text style={{ fontSize: "32px", fontWeight: "700", color: "#202124" }}>Scroll Coordinator</text>
      <scroll-coordinator
        bounces={false}
        refresh-mode="page"
        style={{
          marginTop: "24px",
          width: "100%",
          height: "100%",
          flex: "1",
          display: "flex",
          flexDirection: "column",
          position: "relative",
          overflow: "hidden",
          backgroundColor: "#EDEFF2",
        }}
      >
        {
          /*
          Required, it can be scrolled in scroll coordinator without affecting the layout,
          so it is recommended to set position: absolute.
          No need to place scroll-view or list inside.
        */
        }
        <scroll-coordinator-header
          style={{
            position: "absolute",
            width: "100%",
            height: "360rpx",
          }}
        >
          <view
            style={{
              width: "100%",
              height: "360rpx",
              overflow: "hidden",
            }}
          >
            <image
              mode="aspectFill"
              src={image0}
              style={{
                width: "100%",
                height: "360rpx",
              }}
            />
            <view
              style={{
                position: "absolute",
                left: "0",
                bottom: "0",
                width: "100%",
                padding: "24rpx",
                backgroundColor: "#00000066",
                boxSizing: "border-box",
              }}
            >
              <text style={{ fontSize: "34rpx", fontWeight: "700", color: "#FFFFFF" }}>Forest Ridge</text>
              <text style={{ marginTop: "8rpx", fontSize: "22rpx", color: "#FFFFFF" }}>
                Sunrise views, shaded paths, and easy waypoints.
              </text>
            </view>
          </view>
        </scroll-coordinator-header>

        {
          /*
          Required, its size must be the same as scroll coordinator's size.
          If there is a toolbar, subtract its height.
          After the header is completely collapsed, the slot will occupy the entire scroll coordinator viewport.
          In its child nodes, scrolling can be achieved and can continue after the header is collapsed.
          When placing scroll-view, add enable-new-nested on scroll-view to support nested scrolling interactions.
        */
        }
        <scroll-coordinator-slot
          style={{
            width: "100%",
            flexDirection: "column",
            flex: "1",
            display: "flex",
          }}
        >
          {
            /*
            Optional sticky area. When the header is completely collapsed, it will stay at the top of the slot.
            You can place Tabs modules or any other content here.
            By default it accepts up and down dragging gestures. Use enable-drag to control it.
          */
          }
          <scroll-coordinator-slot-drag style={{ width: "100%" }}>
            <view
              style={{
                width: "100%",
                height: "96rpx",
                display: "flex",
                flexDirection: "row",
                alignItems: "center",
                padding: "0 16rpx",
                backgroundColor: "#FFFFFF",
                boxSizing: "border-box",
              }}
            >
              {tabs.map((tab, index) => {
                const selected = currentPage === index;

                return (
                  <view
                    style={{
                      height: "56rpx",
                      padding: "0 20rpx",
                      marginRight: "12rpx",
                      justifyContent: "center",
                      borderRadius: "8px",
                      backgroundColor: selected ? "#DDF3E5" : "#EEF1F4",
                    }}
                  >
                    <text
                      style={{
                        fontSize: "22rpx",
                        fontWeight: selected ? "700" : "400",
                        color: selected ? "#1F7A4D" : "#4E5969",
                      }}
                    >
                      {tab}
                    </text>
                  </view>
                );
              })}
            </view>
          </scroll-coordinator-slot-drag>
          <viewpager
            style={{
              width: "100%",
              height: "100%",
              flex: "1",
              display: "flex",
              flexDirection: "row",
            }}
            bindwillchange={(e) => {
              setCurrentPage(e.detail.index);
            }}
          >
            {listPages.map((page) => {
              return (
                <viewpager-item
                  style={{
                    width: "100%",
                    height: "100%",
                    flexShrink: 0,
                  }}
                >
                  <refresh
                    ref={(element: NodesRef | null) => {
                      refreshRefs.current[page] = element;
                    }}
                    bindstartrefresh={() => {
                      onStartRefresh(page);
                    }}
                    style={{
                      width: "100%",
                      height: "100%",
                    }}
                  >
                    <refresh-header
                      style={{
                        width: "100%",
                        height: "104rpx",
                        position: "absolute",
                        justifyContent: "center",
                        alignItems: "center",
                        backgroundColor: "#F6F7F9",
                      }}
                    >
                      <image
                        mode="aspectFit"
                        src={loadingGif}
                        style={{
                          width: "48rpx",
                          height: "48rpx",
                        }}
                      />
                      <text style={{ marginTop: "8rpx", fontSize: "20rpx", color: "#4E5969" }}>
                        Refreshing routes...
                      </text>
                    </refresh-header>
                    <list
                      scroll-orientation="vertical"
                      list-type="single"
                      span-count={1}
                      style={{
                        width: "100%",
                        height: "100%",
                        listMainAxisGap: "12px",
                        padding: "12px",
                        boxSizing: "border-box",
                      }}
                    >
                      {listItems.map((item, index) => {
                        return (
                          <list-item
                            item-key={`list-${page}-item-${index}`}
                            key={`list-${page}-item-${index}`}
                          >
                            <view
                              style={{
                                width: "100%",
                                height: "144rpx",
                                display: "flex",
                                flexDirection: "row",
                                alignItems: "center",
                                padding: "12rpx",
                                borderRadius: "8px",
                                backgroundColor: "#FFFFFF",
                                boxSizing: "border-box",
                              }}
                            >
                              <image
                                mode="aspectFill"
                                src={item.image}
                                style={{
                                  width: "120rpx",
                                  height: "120rpx",
                                  borderRadius: "8px",
                                }}
                              />
                              <view
                                style={{
                                  marginLeft: "18rpx",
                                  flex: 1,
                                  flexDirection: "column",
                                }}
                              >
                                <text style={{ fontSize: "28rpx", fontWeight: "700", color: "#202124" }}>
                                  {`${item.title} ${page}`}
                                </text>
                                <text style={{ marginTop: "8rpx", fontSize: "22rpx", color: "#5F6673" }}>
                                  {item.subtitle}
                                </text>
                                <text style={{ marginTop: "10rpx", fontSize: "20rpx", color: "#2D7D46" }}>
                                  {item.tag}
                                </text>
                              </view>
                            </view>
                          </list-item>
                        );
                      })}
                    </list>
                  </refresh>
                </viewpager-item>
              );
            })}
          </viewpager>
        </scroll-coordinator-slot>
      </scroll-coordinator>
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.1



## Attributes

### `android-nested-scroll-as-child`

Android
```tsx
// @defaultValue: false
'android-nested-scroll-as-child'?: boolean;
```

Android foldview is based on CoordinateLayout, but it only implements NestedScrollingParent, so it not support to nested scroll as child in other scrolling widget, set this property true to make it work.

### `bounces`

iOS
Harmony
```tsx
// @defaultValue: true
bounces?: boolean;
```

Enable the bounce effect when the coordinator scrolls past its boundary.

### `enable-scroll`

Android
iOS
Harmony
Clay Android
Clay iOS
```tsx
// @defaultValue: true
'enable-scroll'?: boolean;
```

Set whether the coordinator can scroll vertically.

### `enable-scroll-bar`

iOS
Harmony
```tsx
// @defaultValue: false
'enable-scroll-bar'?: boolean;
```

Set whether the scrollbar is visible during coordinator scrolling.

### `granularity`

Android
iOS
Harmony
Clay Android
Clay iOS
```tsx
// @defaultValue: 0.01
granularity?: number;
```

The event response granularity of bindoffset, once the scroll distance exceeds the scrollable distance of granularity, it may trigger. It defaults to 0.01, but it doesn't necessarily trigger every 0.01.

### `header-over-slot`

Android
iOS
Harmony
Clay Android
Clay iOS
```tsx
// @defaultValue: false
'header-over-slot'?: boolean;
```

This property controls whether the header hierarchy higher than the slot, when header is overflow, it will be displayed on top of the slot. Otherwise, it will be displayed below the slot. It is better to set this property explicitly, rather than use the default value.

### `ios-force-scroll-detach`

iOS
```tsx
// @defaultValue: false
'ios-force-scroll-detach'?: boolean;
```

Whether to force the nested-vertical-scroll-behavior invalid of foldview on iOS, the setting is ineffective for other platforms

### `ios-scrolls-to-top`

iOS
```tsx
// @defaultValue: false
'ios-scrolls-to-top'?: boolean;
```

When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top. iOS feature only.

### `refresh-mode`

iOS
```tsx
// @defaultValue: 'none'
'refresh-mode'?: 'page' | 'none' | 'fold';
```

The pull-to-refresh mode of foldview, none (none, default value), page (category pull-to-refresh), fold (overall pull-to-refresh)

## Events

Frontend can bind corresponding event callbacks to listen for runtime behaviors of the element, as shown below.

### `bindoffset`

Android
iOS
Harmony
Clay Android
Clay iOS
```tsx
bindoffset = (e: ScrollCoordinatorOffsetEvent) => {};
```

| Field | Type | Optional | Default | Platforms | Since | Description |
| --- | --- | --- | --- | --- | --- | --- |
| height | number | No | – | Android iOS Harmony Clay Android Clay iOS |  | The absolute value of the scrollable distance (header height - toolbar height), in px |
| offset | number | No | – | Android iOS Harmony Clay Android Clay iOS |  | The absolute value of the header scroll offset, in px |

Callback for folding progress

## Methods

Frontend can invoke component methods via the [SelectorQuery](/next/api/lynx-api/nodes-ref/nodes-ref-invoke.md) API.

### `setFoldExpanded`

```ts

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'setFoldExpanded',
      params: {
        /**
         * Offset, supports px and rpx
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @PC
         */
        offset: '0px',
        /**
         * Whether folding requires animation
         * @Android
         * @iOS
         * @Harmony
         * @Web
         * @PC
         */
        smooth: true,
      },
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

```

## Compatibility

**Compatibility Table**

**Query:** `elements.scroll-coordinator`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| scroll-coordinator | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes |
| attributes | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes (3.9) | Partial |
| attributes.ios-scrolls-to-top | No | No | Yes (3.9) | No | No | No |
| attributes.header-over-slot | Yes (3.9) | Yes (3.9) | Yes (3.9) | No | No | Yes |
| attributes.enable-scroll | Yes (3.9) | Yes (3.9) | Yes (3.9) | No | No | No |
| attributes.bounces | No | Yes (3.9) | Yes (3.9) | No | No | No |
| attributes.enable-scroll-bar | No | Yes (3.9) | Yes (3.9) | No | No | No |
| attributes.android-nested-scroll-as-child | Yes (3.9) | No | No | No | No | No |
| attributes.ios-force-scroll-detach | No | No | Yes (3.9) | No | No | No |
| attributes.granularity | Yes (3.9) | Yes (3.9) | Yes (3.9) | No | No | Yes |
| attributes.refresh-mode | No | No | Yes (3.9) | No | No | No |
| attributes.enable-drag | Yes (3.9) | No | Yes (3.9) | No | No | No |
| events | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes |
| events.bindoffset | Yes (3.9) | Yes (3.9) | Yes (3.9) | No | No | Yes |
| methods | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes (3.9) | Yes |
| methods.setFoldExpanded | Yes (3.9) | Yes (3.9) | Yes (3.9) | No | No | Yes |
| methods.boundingClientRect | Yes (3.9) | Yes (4.0) | Yes (4.0) | No | No | Yes |
| methods.requestAccessibilityFocus | Yes (3.9) | No | Yes (4.0) | No | No | No |
| methods.scrollIntoView | Yes (4.0) | Yes (4.0) | Yes (4.0) | No | No | Yes |
| methods.setFocus | No | No | No | No | No | No |
| methods.takeScreenshot | Yes (4.0) | Yes (4.0) | Yes (4.0) | No | No | No |

**`scroll-coordinator`**

scroll-coordinator

**`attributes`**

attributes

- **Web — Supported (version unknown):** Partial support; Supports header-over-slot and granularity. Web scroll controls use scroll-enable and scroll-bar-enable instead of enable-scroll and enable-scroll-bar.

**`attributes.ios-scrolls-to-top`**

<code>ios-scrolls-to-top</code>

**`attributes.header-over-slot`**

<code>header-over-slot</code>

**`attributes.enable-scroll`**

<code>enable-scroll</code>

**`attributes.bounces`**

<code>bounces</code>

**`attributes.enable-scroll-bar`**

<code>enable-scroll-bar</code>

**`attributes.android-nested-scroll-as-child`**

<code>android-nested-scroll-as-child</code>

**`attributes.ios-force-scroll-detach`**

<code>ios-force-scroll-detach</code>

**`attributes.granularity`**

<code>granularity</code>

**`attributes.refresh-mode`**

<code>refresh-mode</code>

**`attributes.enable-drag`**

<code>enable-drag</code>

**`events`**

events

**`events.bindoffset`**

<code>bindoffset</code>

**`methods`**

methods

**`methods.setFoldExpanded`**

<code>setFoldExpanded</code>

**`methods.boundingClientRect`**

<code>boundingClientRect</code>

**`methods.requestAccessibilityFocus`**

<code>requestAccessibilityFocus</code>

**`methods.scrollIntoView`**

<code>scrollIntoView</code>

- **Web — Supported (version unknown):** Uses the browser element method.

**`methods.setFocus`**

<code>setFocus</code>

**`methods.takeScreenshot`**

<code>takeScreenshot</code>

