Skip to content

Commit

Permalink
Update header.js to account for gap between navigation items
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Oct 22, 2024
1 parent bbac682 commit 458b27d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ class Header {
*
*/
calculateBreakpoints() {
// Get the width of the gap between each navigation item
const navigationListStyles = window.getComputedStyle(this.navigationList)
const gapPixels = navigationListStyles.getPropertyValue('gap')
const gap = Number(gapPixels.replace('px', ''))

let childrenWidth = 0
for (let i = 0; i < this.navigationList.children.length; i++) {
childrenWidth += this.navigationList.children[i].offsetWidth
childrenWidth += this.navigationList.children[i].offsetWidth + gap
this.breakpoints[i] = childrenWidth
}
}
Expand Down

0 comments on commit 458b27d

Please sign in to comment.