From 3e9c778a527f85a8dfabbc312bc00d18c554d5eb Mon Sep 17 00:00:00 2001 From: lareinayanyu Date: Thu, 9 Jan 2025 20:06:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20offsetY=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webpack-plugin/lib/runtime/components/react/mpx-video.tsx | 2 +- .../webpack-plugin/lib/runtime/components/react/utils.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx index 02417fb42e..132139e26a 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx @@ -188,7 +188,7 @@ const MpxVideo = forwardRef, VideoProps>((videoProp hasSelfPercent, setWidth, setHeight, - nodeRef: videoRef + nodeRef: viewRef }) useNodesRef(props, ref, viewRef, { diff --git a/packages/webpack-plugin/lib/runtime/components/react/utils.tsx b/packages/webpack-plugin/lib/runtime/components/react/utils.tsx index 08fac95572..572dc2b674 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/utils.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/utils.tsx @@ -511,6 +511,7 @@ export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout const hasLayoutRef = useRef(false) const layoutStyle = useMemo(() => { return !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {} }, [hasLayoutRef.current]) const layoutProps: Record = {} + const navigation = useNavigation() const enableOffset = props['enable-offset'] if (hasSelfPercent || onLayout || enableOffset) { layoutProps.onLayout = (e: LayoutChangeEvent) => { @@ -522,7 +523,8 @@ export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout } if (enableOffset) { nodeRef.current?.measure((x: number, y: number, width: number, height: number, offsetLeft: number, offsetTop: number) => { - layoutRef.current = { x, y, width, height, offsetLeft, offsetTop } + const { y: navigationY = 0 } = navigation?.layout || {} + layoutRef.current = { x, y: y - navigationY, width, height, offsetLeft, offsetTop: offsetTop - navigationY } }) } onLayout && onLayout(e)