Skip to content

Commit

Permalink
Add on scroll handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskerr committed Apr 4, 2024
1 parent 9179af3 commit fd6a30a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/react-arborist/src/components/tree-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function TreeViewContainer() {
outerRef={outerRef}
innerElementType={ListInner as any}
direction={tree.props.direction}
// onScroll={tree.props.onScroll}
onScroll={tree.props.onScroll}
ref={(node) => {
tree.listElement = node;
tree.visibleStartIndex;
Expand Down
3 changes: 3 additions & 0 deletions modules/react-arborist/src/props/use-default-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export function useDefaultProps<T>(
overscanCount: props.overscanCount ?? 1,
direction: "ltr",

/* Callbacks */
onScroll: props.onScroll ?? (() => {}),

/* Class names */
className: props.className,
rowClassName: props.rowClassName,
Expand Down
4 changes: 4 additions & 0 deletions modules/react-arborist/src/types/tree-view-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FocusPartialController } from "../focus/types";
import { VisiblePartialController } from "../visible/types";
import { ShortcutAttrs } from "../shortcuts/types";
import { CommandObject } from "../commands/types";
import { ListOnScrollProps } from "react-window";

export type TreeViewProps<T> = {
/* Partial Controllers */
Expand Down Expand Up @@ -35,6 +36,9 @@ export type TreeViewProps<T> = {
padding: number;
direction: "rtl" | "ltr";

/* Callbacks */
onScroll: (args: ListOnScrollProps) => void;

/* Class Names */
className?: string;
rowClassName?: string;
Expand Down
2 changes: 1 addition & 1 deletion modules/showcase/pages/version4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Version4() {
nodes={nodes}
className="tree"
rowClassName="tree-row"
height={900}
height={100}
{...filterProps}
/>
<input
Expand Down

0 comments on commit fd6a30a

Please sign in to comment.