Add offset to custom positioning. Reusing existing prop
This commit is contained in:
parent
5ee95c4080
commit
7895292705
|
@ -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") {
|
||||||
|
|
|
@ -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">
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue