Skip to content

Commit

Permalink
fix: lint of menuitem
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyatong committed Oct 10, 2024
1 parent bb1d254 commit 693adb6
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/packages/menuitem/menuitem.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,21 @@ export const MenuItem = forwardRef((props: Partial<MenuItemProps>, ref) => {
useEffect(() => {
setShowPopup(show)
}, [show])

const getParentOffset = useCallback(() => {
setTimeout(async () => {
const p = parent.menuRef.current
const rect = await getRectByTaro(p)
setPosition({
height: rect.height,
top: rect.top,
})
}, 100)
}, [parent.menuRef])

useEffect(() => {
getParentOffset()
}, [showPopup])
}, [showPopup, getParentOffset])

const windowHeight = useMemo(() => getSystemInfoSync().windowHeight, [])
const updateItemOffset = useCallback(() => {
Expand All @@ -106,7 +118,8 @@ export const MenuItem = forwardRef((props: Partial<MenuItemProps>, ref) => {
})
}
})
}, [direction, windowHeight])
}, [direction, windowHeight, parent.lockScroll, parent.menuRef])

usePageScroll(updateItemOffset)

useImperativeHandle<any, any>(ref, () => ({
Expand Down Expand Up @@ -136,16 +149,7 @@ export const MenuItem = forwardRef((props: Partial<MenuItemProps>, ref) => {
top: 0,
height: 0,
})
const getParentOffset = () => {
setTimeout(async () => {
const p = parent.menuRef.current
const rect = await getRectByTaro(p)
setPosition({
height: rect.height,
top: rect.top,
})
}, 100)
}

const isShow = () => {
if (showPopup) return {}
return { display: 'none' }
Expand Down

0 comments on commit 693adb6

Please sign in to comment.