Skip to content

Commit

Permalink
doc upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Morglod committed Jul 11, 2024
1 parent 10ff537 commit 21646c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-virtual-overflow",
"version": "1.0.0",
"version": "1.0.1",
"description": "virtual scroll without headache",
"main": "lib/index.cjs.js",
"module": "lib/index.esm.js",
Expand Down
21 changes: 10 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ This method will find only parents with overflow style set and calculate clippin
Also if you know all containers with scroll (which you can find with `findScrollContainerTopStack`) you can calculate directly with `calcVisibleRectWithStack`.

```tsx
import { virtualOverflowUtils } from "react-virtual-overflow/utils";
import { virtualOverflowUtils } from "react-virtual-overflow/lib/utils";

// in component
const [parentsWithOverflow, setParentsWithOverflow] = useState([] as any[]);
Expand All @@ -104,17 +104,16 @@ useLayoutEffect(() => {
setParentsWithOverflow(stack);
}, []);

const rendered = useVirtualOverflowV(
{
containerRef,
itemsLength,
itemHeight,
calcVisibleRect: (el: HTMLElement) => {
// calculate only by found overflows
return virtualOverflowUtils.calcVisibleRectWithStack(el, parentsWithOverflow);
},
renderItem,
const rendered = useVirtualOverflowV({
containerRef,
itemsLength,
itemHeight,
calcVisibleRect: (el: HTMLElement) => {
// calculate only by found overflows
return virtualOverflowUtils.calcVisibleRectWithStack(el, parentsWithOverflow);
},
renderItem,
},
// add overflow stack to deps
[parentsWithOverflow]
);
Expand Down

0 comments on commit 21646c4

Please sign in to comment.