@sustaina/shared-ui 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -869,15 +869,33 @@ var DataTable = ({
|
|
|
869
869
|
}, [centerVisibleLeafColumns, leftVisibleLeftColumns, rightVisibleLeafColumns]);
|
|
870
870
|
const fetchMoreOnScrollReached = useCallback(
|
|
871
871
|
(containerRefElement) => {
|
|
872
|
-
if (!scrollFetch?.enabled) {
|
|
872
|
+
if (!scrollFetch?.enabled || !containerRefElement || scrollFetch?.isFetchingMore || !scrollFetch?.hasMore || !scrollFetch?.fetchMore) {
|
|
873
873
|
return;
|
|
874
874
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
875
|
+
const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
|
|
876
|
+
const scrollableHeight = scrollHeight - clientHeight;
|
|
877
|
+
const distanceToBottom = scrollHeight - clientHeight - scrollTop;
|
|
878
|
+
const ratioToBottom = scrollableHeight > 0 ? scrollTop / scrollableHeight : 1;
|
|
879
|
+
const info = {
|
|
880
|
+
scrollTop,
|
|
881
|
+
scrollHeight,
|
|
882
|
+
clientHeight,
|
|
883
|
+
scrollableHeight,
|
|
884
|
+
distanceToBottom,
|
|
885
|
+
ratioToBottom,
|
|
886
|
+
isTopReached: scrollTop === 0,
|
|
887
|
+
isBottomReached: distanceToBottom <= 0
|
|
888
|
+
};
|
|
889
|
+
let shouldTrigger = false;
|
|
890
|
+
if (typeof scrollFetch.scrollThreshold === "number") {
|
|
891
|
+
shouldTrigger = info.ratioToBottom >= scrollFetch.scrollThreshold;
|
|
892
|
+
} else if (typeof scrollFetch.scrollThreshold === "function") {
|
|
893
|
+
shouldTrigger = scrollFetch.scrollThreshold(info);
|
|
894
|
+
} else {
|
|
895
|
+
shouldTrigger = info.ratioToBottom >= 0.7;
|
|
896
|
+
}
|
|
897
|
+
if (shouldTrigger) {
|
|
898
|
+
scrollFetch.fetchMore();
|
|
881
899
|
}
|
|
882
900
|
},
|
|
883
901
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|