Skip to content

Commit

Permalink
fix: offsetY计算
Browse files Browse the repository at this point in the history
  • Loading branch information
lareinayanyu committed Jan 9, 2025
1 parent c30f2fb commit 3e9c778
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
hasSelfPercent,
setWidth,
setHeight,
nodeRef: videoRef
nodeRef: viewRef
})

useNodesRef(props, ref, viewRef, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any> = {}
const navigation = useNavigation()
const enableOffset = props['enable-offset']
if (hasSelfPercent || onLayout || enableOffset) {
layoutProps.onLayout = (e: LayoutChangeEvent) => {
Expand All @@ -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)
Expand Down

0 comments on commit 3e9c778

Please sign in to comment.