1
0
Fork 0
mirror of synced 2024-07-11 09:15:48 +12:00

Add offset to custom positioning. Reusing existing prop

This commit is contained in:
Dean 2024-02-15 16:16:30 +00:00
parent 5ee95c4080
commit 7895292705
4 changed files with 8 additions and 4 deletions

View file

@ -35,7 +35,10 @@ export default function positionDropdown(element, opts) {
}
if (typeof customUpdate === "function") {
styles = customUpdate(anchorBounds, elementBounds, styles)
styles = customUpdate(anchorBounds, elementBounds, {
...styles,
offset: opts.offset,
})
} else {
// Determine vertical styles
if (align === "right-outside") {

View file

@ -86,6 +86,7 @@
showPopover={drawers.length === 0}
clickOutsideOverride={drawers.length > 0}
maxHeight={600}
offset={18}
handlePostionUpdate={customPositionHandler}
>
<span class="popover-wrap">

View file

@ -1,8 +1,8 @@
export const customPositionHandler = (anchorBounds, eleBounds, cfg) => {
let { left, top } = cfg
let { left, top, offset } = cfg
let percentageOffset = 30
// left-outside
left = anchorBounds.left - eleBounds.width - 18
left = anchorBounds.left - eleBounds.width - (offset || 5)
// shift up from the anchor, if space allows
let offsetPos = Math.floor(eleBounds.height / 100) * percentageOffset

View file

@ -95,7 +95,7 @@
anchor={popoverAnchor}
maxWidth={300}
dismissible={false}
offset={15}
offset={12}
handlePostionUpdate={tourStep?.positionHandler}
customZindex={3}
>