Skip to content

Fix Issue 70 #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/TopNav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const TopNav = ({
if (!cache.refs[menu.id]) return menu
cache.slide[menu.id] = true
const el = cache.refs[menu.id]
if (!el) return menu
const rect = el.getBoundingClientRect()
return {
...menu,
Expand All @@ -121,6 +122,7 @@ const TopNav = ({

const getMenuCenter = useCallback(menuId => {
const el = cache.refs[menuId]
if (!el) return
const rect = el.getBoundingClientRect()
return rect.left + rect.width / 2
}, [cache.refs])
Expand Down Expand Up @@ -267,6 +269,7 @@ const TopNav = ({
if (!cache.slide[menu.id] || !cache.refs[menu.id]) return
cache.slide[menu.id] = false
const el = cache.refs[menu.id]
if (!el) return
const rect = el.getBoundingClientRect()
const relativeX = menu.initialX - rect.left
el.style.transform = `translateX(${relativeX}px)`
Expand Down Expand Up @@ -310,6 +313,7 @@ const TopNav = ({
if (!menuEl) return
const rect = menuEl.getBoundingClientRect()
if (!prect) {
if (!menuEl.parentElement) return
prect = menuEl.parentElement.getBoundingClientRect()
}
// add the item if it's overflowing
Expand Down