pb-sxp-ui 1.19.9 → 1.19.10
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.cjs +67 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -2
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +67 -2
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/index.js +4 -2
- package/es/core/hooks/useVisibleHeight.d.ts +1 -0
- package/es/core/hooks/useVisibleHeight.js +52 -0
- package/lib/core/components/SxpPageRender/index.js +4 -2
- package/lib/core/hooks/useVisibleHeight.d.ts +1 -0
- package/lib/core/hooks/useVisibleHeight.js +56 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -19000,6 +19000,70 @@ const NavBack = ({ data, minusHeight, tagHeight, onClick }) => {
|
|
|
19000
19000
|
};
|
|
19001
19001
|
var NavBack$1 = React.memo(NavBack);
|
|
19002
19002
|
|
|
19003
|
+
const useVisibleHeight = () => {
|
|
19004
|
+
const [visibleHeight, setVisibleHeight] = React.useState(0);
|
|
19005
|
+
const getVisibleContentHeight = () => {
|
|
19006
|
+
// 方法优先级:
|
|
19007
|
+
// 1. visualViewport.height (最准确)
|
|
19008
|
+
// 2. window.innerHeight (次之)
|
|
19009
|
+
// 3. document.documentElement.clientHeight (fallback)
|
|
19010
|
+
if (typeof window === 'undefined')
|
|
19011
|
+
return 0;
|
|
19012
|
+
let height = window.innerHeight;
|
|
19013
|
+
// 优先使用 visualViewport
|
|
19014
|
+
if (window.visualViewport) {
|
|
19015
|
+
height = window.visualViewport.height;
|
|
19016
|
+
}
|
|
19017
|
+
// 验证高度合理性
|
|
19018
|
+
if (height <= 0 || height > window.screen.height) {
|
|
19019
|
+
height = window.innerHeight;
|
|
19020
|
+
}
|
|
19021
|
+
// 最终 fallback
|
|
19022
|
+
if (height <= 0) {
|
|
19023
|
+
height = document.documentElement.clientHeight;
|
|
19024
|
+
}
|
|
19025
|
+
return height;
|
|
19026
|
+
};
|
|
19027
|
+
const updateHeight = React.useCallback(() => {
|
|
19028
|
+
const height = getVisibleContentHeight();
|
|
19029
|
+
setVisibleHeight(height);
|
|
19030
|
+
}, []);
|
|
19031
|
+
React.useEffect(() => {
|
|
19032
|
+
// 初始计算
|
|
19033
|
+
updateHeight();
|
|
19034
|
+
// 事件监听
|
|
19035
|
+
const events = ['resize', 'orientationchange', 'load', 'DOMContentLoaded'];
|
|
19036
|
+
events.forEach((event) => {
|
|
19037
|
+
window.addEventListener(event, updateHeight);
|
|
19038
|
+
});
|
|
19039
|
+
// visualViewport 监听(最重要)
|
|
19040
|
+
if (window.visualViewport) {
|
|
19041
|
+
window.visualViewport.addEventListener('resize', updateHeight);
|
|
19042
|
+
window.visualViewport.addEventListener('scroll', updateHeight);
|
|
19043
|
+
}
|
|
19044
|
+
// 键盘弹出/收起监听(移动端重要)
|
|
19045
|
+
if ('virtualKeyboard' in navigator) {
|
|
19046
|
+
navigator.virtualKeyboard.addEventListener('geometrychange', updateHeight);
|
|
19047
|
+
}
|
|
19048
|
+
// 定期检查(应对某些特殊情况)
|
|
19049
|
+
const interval = setInterval(updateHeight, 1000);
|
|
19050
|
+
return () => {
|
|
19051
|
+
events.forEach((event) => {
|
|
19052
|
+
window.removeEventListener(event, updateHeight);
|
|
19053
|
+
});
|
|
19054
|
+
if (window.visualViewport) {
|
|
19055
|
+
window.visualViewport.removeEventListener('resize', updateHeight);
|
|
19056
|
+
window.visualViewport.removeEventListener('scroll', updateHeight);
|
|
19057
|
+
}
|
|
19058
|
+
if ('virtualKeyboard' in navigator) {
|
|
19059
|
+
navigator.virtualKeyboard.removeEventListener('geometrychange', updateHeight);
|
|
19060
|
+
}
|
|
19061
|
+
clearInterval(interval);
|
|
19062
|
+
};
|
|
19063
|
+
}, [updateHeight]);
|
|
19064
|
+
return visibleHeight;
|
|
19065
|
+
};
|
|
19066
|
+
|
|
19003
19067
|
/*
|
|
19004
19068
|
* @Author: binruan@chatlabs.com
|
|
19005
19069
|
* @Date: 2024-03-20 10:27:31
|
|
@@ -19028,6 +19092,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19028
19092
|
const fbcRef = React.useRef('');
|
|
19029
19093
|
const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession, isDiyH5, pixelPvStatusRef } = useSxpDataSource();
|
|
19030
19094
|
const { backMainFeed, productView, jumpToWeb } = useEventReport();
|
|
19095
|
+
const visibleHeight = useVisibleHeight();
|
|
19031
19096
|
const isShowFingerTip = React.useMemo(() => {
|
|
19032
19097
|
return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
|
|
19033
19098
|
}, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
|
|
@@ -19212,8 +19277,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19212
19277
|
return safeAreaBottom;
|
|
19213
19278
|
};
|
|
19214
19279
|
const height = React.useMemo(() => {
|
|
19215
|
-
return
|
|
19216
|
-
}, [minusHeight,
|
|
19280
|
+
return visibleHeight - minusHeight - tagHeight;
|
|
19281
|
+
}, [minusHeight, visibleHeight, tagHeight]);
|
|
19217
19282
|
const visList = React.useMemo(() => {
|
|
19218
19283
|
var _a;
|
|
19219
19284
|
const list = activeIndex === 0 && !waterFallData && !isEditor && !isDiyH5
|