Scroll Box
It saves and restores the scroll position inside the Split screen based on keyName.
Basic usage
FlexLayoutSplitScreenScrollBoxrestores scrollLeft/scrollTop to the saved position on mount, and throttles the scroll event to save to the store.
"use client";
import { FlexLayoutSplitScreenScrollBox } from "@byeolnaerim/flex-layout";
export default function CustomerList() {
return (
<FlexLayoutSplitScreenScrollBox
keyName="customer-list"
direction="y"
style={{ height: 240, overflowY: "auto" }}
>
{Array.from({ length: 40 }, (_, index) => (
<div key={index} style={{ padding: 12 }}>
Customer {index + 1}
</div>
))}
</FlexLayoutSplitScreenScrollBox>
);
}State lifetime and verification
높이가 제한되어야 박스 내부에서 스크롤됩니다. 각 박스에는 서로 다른 keyName을 사용합니다. 현재 구현은 70ms throttle로 위치를 저장하고, unmount 또는 keyName 변경 시 이전 키를 삭제합니다. 따라서 탭을 숨겨 mount를 유지하는 경우와 컴포넌트를 제거하는 경우는 다르며, 새로고침 후 복원을 보장하지 않습니다.
horizontal wheel scroll
direction="x"converts the wheel deltaY to horizontal scrollLeft when given.
props
keyName
The key used to save and restore the scroll position.
direction
Either x or y. With x, the wheel scrolls horizontally.
listScrollClassName
A custom scrollbar style class. When provided, it is combined with default-scroll instead of the direction-based list-scroll class.
className
An external style class combined with the built-in styles.