@yakad/ui 1.3.132 → 1.3.133
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.
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
|
-
import { jsx as _jsx
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import React, { forwardRef, useEffect, useState } from "react";
|
|
15
15
|
import classNames from "classnames";
|
|
16
16
|
import boxingStyles from "../boxing.module.css";
|
|
@@ -27,8 +27,9 @@ export const LoadingControlV2 = forwardRef(function LoadingControlV2(_a, ref) {
|
|
|
27
27
|
]);
|
|
28
28
|
const [visibilityStatus, setVisibilityStatus] = useState({});
|
|
29
29
|
const handleOnVisibilityChange = (visible, i) => {
|
|
30
|
-
if (i !== undefined
|
|
31
|
-
|
|
30
|
+
if (i !== undefined)
|
|
31
|
+
if (visibilityStatus[i] !== visible)
|
|
32
|
+
setVisibilityStatus((prev) => (Object.assign(Object.assign({}, prev), { [i]: visible })));
|
|
32
33
|
};
|
|
33
34
|
const visibleIndexes = Object.entries(visibilityStatus)
|
|
34
35
|
// eslint-disable-next-line
|
|
@@ -79,7 +80,7 @@ export const LoadingControlV2 = forwardRef(function LoadingControlV2(_a, ref) {
|
|
|
79
80
|
}
|
|
80
81
|
// eslint-disable-next-line
|
|
81
82
|
}, [visibilityStatus]);
|
|
82
|
-
console.log("###### ", "Total Loaded:", loadedItems.length, "
|
|
83
|
+
console.log("###### ", "Total Loaded:", loadedItems.length, "extraLoading:", extraLoading, " ##### ", "L:", lowestLoadedItemIndex, "V:", lowestVisibleItemIndex, "D:", -(lowestLoadedItemIndex - lowestVisibleItemIndex), "|", "V:", visibleCount, "|", "D:", highestLoadedItemIndex - highestVisibleItemIndex, "V:", highestVisibleItemIndex, "L:", highestLoadedItemIndex);
|
|
83
84
|
// console.log("visibilityStatus", visibilityStatus);
|
|
84
85
|
// console.log(
|
|
85
86
|
// "loadedItems",
|
|
@@ -90,5 +91,5 @@ export const LoadingControlV2 = forwardRef(function LoadingControlV2(_a, ref) {
|
|
|
90
91
|
// Object.keys(visibilityStatus).length
|
|
91
92
|
// );
|
|
92
93
|
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { fullWidth: fullWidth }, className);
|
|
93
|
-
return (_jsx("div", Object.assign({ ref: ref, className: joinedClassNames }, restProps, { children: loadedItems.map((item) => (
|
|
94
|
+
return (_jsx("div", Object.assign({ ref: ref, className: joinedClassNames }, restProps, { children: loadedItems.map((item) => (_jsx(DisplayOnVisible, { onVisibilityChange: (visible) => handleOnVisibilityChange(visible, item.props.index), children: item }, item.props.index))) })));
|
|
94
95
|
});
|
|
@@ -14,6 +14,7 @@ export interface WithInteractionsProps {
|
|
|
14
14
|
onScrollStart?: () => void;
|
|
15
15
|
onScrollStop?: () => void;
|
|
16
16
|
onResize?: (entry: ResizeObserverEntry) => void;
|
|
17
|
+
onVisibilityChange?: (visible: boolean) => void;
|
|
17
18
|
onVisible?: () => void;
|
|
18
19
|
onHidden?: () => void;
|
|
19
20
|
onMouseHoverStart?: (e: MouseEvent) => void;
|
|
@@ -14,7 +14,7 @@ import { mergeRefs } from "@yakad/lib";
|
|
|
14
14
|
import { cloneElement, forwardRef, isValidElement, useEffect, useImperativeHandle, useRef, } from "react";
|
|
15
15
|
export const WithInteractions = forwardRef(function WithInteractions(_a, forwardedRef) {
|
|
16
16
|
var _b;
|
|
17
|
-
var { children, onRightClick, onTap, onDoubleTap, onOutsideClick, onSwipeLeft, onSwipeRight, onSwipeUp, onSwipeDown, onPinchIn, onPinchOut, onRotate, onScrollStart, onScrollStop, onResize, onVisible, onHidden, onMouseHoverStart, onMouseHoverLeave } = _a, restProps = __rest(_a, ["children", "onRightClick", "onTap", "onDoubleTap", "onOutsideClick", "onSwipeLeft", "onSwipeRight", "onSwipeUp", "onSwipeDown", "onPinchIn", "onPinchOut", "onRotate", "onScrollStart", "onScrollStop", "onResize", "onVisible", "onHidden", "onMouseHoverStart", "onMouseHoverLeave"]);
|
|
17
|
+
var { children, onRightClick, onTap, onDoubleTap, onOutsideClick, onSwipeLeft, onSwipeRight, onSwipeUp, onSwipeDown, onPinchIn, onPinchOut, onRotate, onScrollStart, onScrollStop, onResize, onVisibilityChange, onVisible, onHidden, onMouseHoverStart, onMouseHoverLeave } = _a, restProps = __rest(_a, ["children", "onRightClick", "onTap", "onDoubleTap", "onOutsideClick", "onSwipeLeft", "onSwipeRight", "onSwipeUp", "onSwipeDown", "onPinchIn", "onPinchOut", "onRotate", "onScrollStart", "onScrollStop", "onResize", "onVisibilityChange", "onVisible", "onHidden", "onMouseHoverStart", "onMouseHoverLeave"]);
|
|
18
18
|
const localRef = useRef(null);
|
|
19
19
|
// Let the parent access our DOM node
|
|
20
20
|
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
@@ -151,9 +151,10 @@ export const WithInteractions = forwardRef(function WithInteractions(_a, forward
|
|
|
151
151
|
}
|
|
152
152
|
// === VISIBILITY OBSERVER ===
|
|
153
153
|
let intersectionObserver = null;
|
|
154
|
-
if (onVisible || onHidden) {
|
|
154
|
+
if (onVisibilityChange || onVisible || onHidden) {
|
|
155
155
|
intersectionObserver = new IntersectionObserver((entries) => {
|
|
156
156
|
entries[0].isIntersecting ? onVisible === null || onVisible === void 0 ? void 0 : onVisible() : onHidden === null || onHidden === void 0 ? void 0 : onHidden();
|
|
157
|
+
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(entries[0].isIntersecting);
|
|
157
158
|
});
|
|
158
159
|
intersectionObserver.observe(el);
|
|
159
160
|
cleanupFns.push(() => intersectionObserver === null || intersectionObserver === void 0 ? void 0 : intersectionObserver.disconnect());
|
|
@@ -207,6 +208,7 @@ export const WithInteractions = forwardRef(function WithInteractions(_a, forward
|
|
|
207
208
|
onScrollStart,
|
|
208
209
|
onScrollStop,
|
|
209
210
|
onResize,
|
|
211
|
+
onVisibilityChange,
|
|
210
212
|
onVisible,
|
|
211
213
|
onHidden,
|
|
212
214
|
onMouseHoverStart,
|