1
0
Fork 0
mirror of synced 2024-09-08 21:51:58 +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") { if (typeof customUpdate === "function") {
styles = customUpdate(anchorBounds, elementBounds, styles) styles = customUpdate(anchorBounds, elementBounds, {
...styles,
offset: opts.offset,
})
} else { } else {
// Determine vertical styles // Determine vertical styles
if (align === "right-outside") { if (align === "right-outside") {

View file

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

View file

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

View file

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