UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

31 lines (30 loc) 1.48 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import InfiniteScroll from '../index'; const style = { height: 30, border: '1px solid green', margin: 6, padding: 8 }; export default function ScrollableTargetFixedInfScroll() { const [items, setItems] = useState(Array.from({ length: 20 })); const fetchMoreData = () => { // a fake async api call like which sends // 20 more records in 1.5 secs setTimeout(() => { setItems(items.concat(Array.from({ length: 20 }))); }, 1500); }; return (_jsxs("div", { children: [_jsx("h1", { children: "demo: Infinite Scroll with scrollable target FIXED" }), _jsx("hr", {}), _jsx("div", Object.assign({ id: "scrollableDiv", style: { position: 'fixed', bottom: 0, left: 0, right: 0, top: 170, zIndex: 1000, maxWidth: '100% !important', height: '50vh', overflowY: 'scroll' } }, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: items.length, hasMoreNext: true, next: fetchMoreData, loaderNext: _jsx("h4", { children: "Loading..." }), scrollableTarget: "scrollableDiv" }, { children: items.map((_, index) => (_jsxs("div", Object.assign({ style: style }, { children: ["div - #", index] }), index))) })) }))] })); }