mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-30 18:16:48 +10:00
Update content positioning logic naming
Also apply content offset to menu content that's placed to the right from the label.
This commit is contained in:
parent
ade84a9824
commit
c33752e8b8
1 changed files with 6 additions and 3 deletions
|
|
@ -97,11 +97,14 @@ class Menu extends Component {
|
|||
const distanceToRight = window.innerWidth - this.menu.getBoundingClientRect().right;
|
||||
const menuWidth = this.menu.offsetWidth;
|
||||
const contentWidthBiggerThanLabel = this.menuContent.offsetWidth - menuWidth;
|
||||
const usePositionRightFromLabel = contentPosition === CONTENT_TO_LEFT;
|
||||
const usePositionLeftFromLabel = contentPosition === CONTENT_TO_LEFT;
|
||||
const contentPlacementOffset = this.props.contentPlacementOffset;
|
||||
return usePositionRightFromLabel || distanceToRight < contentWidthBiggerThanLabel
|
||||
// Render menu content to the left according to the contentPosition
|
||||
// prop or if the content does not fit to the right. Otherwise render to
|
||||
// the right.
|
||||
return usePositionLeftFromLabel || distanceToRight < contentWidthBiggerThanLabel
|
||||
? { right: contentPlacementOffset, minWidth: menuWidth }
|
||||
: { left: 0, minWidth: menuWidth };
|
||||
: { left: contentPlacementOffset, minWidth: menuWidth };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue