-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor popover positioning service #1
Refactor popover positioning service #1
Conversation
…steps: 1) Find original cross-axis position. 2) Apply shift to cross-axis position, if necessary. 3) Find primary axis position.
…imaryAxisPosition helper functions.
|
||
const { | ||
bestPosition, | ||
} = iterationPositions.reduce(({ bestFit, bestPosition }, iterationPosition) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the encapsulation of using reduce
because you don't need to mutate external variables, but it's a little inefficient because it always loops 4 times, even if the best fit has already been found. I don't mind if you want to switch this back to a for
loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like seeing it this way
|
||
// the popover's original position on the cross-axis is determined by: | ||
const crossAxisPositionOriginal = | ||
anchorBoundingBox[crossAxisFirstSide] // where the anchor is located |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice formatting!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it!
Altered styles and added some props
Update defazio fork to 13.0
Thread generics throughout EuiBasicTable
* removed duplicate icons * Fixing changelog and updating tests (#1) Co-authored-by: Caroline Horn <[email protected]>
fix prettier / ts issues
I broke this PR into the following steps, with corresponding commits:
getPopoverScreenCoordinates
into discrete steps:a) Find original cross-axis position.
b) Apply shift to cross-axis position, if necessary.
c) Find primary axis position.
getCrossAxisPosition
andgetPrimaryAxisPosition
helper functions, which also encapsulate the arrow-positioning logic for each axis. The primary axis arrow positioning logic was both adding and subtractingpositioning[primaryAxisPositionName]
, so I removed those operations.iterationPositions
array ingetPopoverScreenCoordinates
, which we traverse to get the best-fitting position, instead of defining the next iteration position in each loop. I found it easier to understand the strategy this way.