diff options
| author | Shpuld Shpuldson <shp@cock.li> | 2020-11-25 18:33:08 +0200 |
|---|---|---|
| committer | Shpuld Shpuldson <shp@cock.li> | 2020-11-25 18:33:08 +0200 |
| commit | 2137d6395acf3c9a2b440af2fa9bcfe8a4de04d4 (patch) | |
| tree | 78e6f8d23985bb9201dcb2bf9d6f97f419321cb1 /src/components/popover/popover.js | |
| parent | e771fd8f135e5f1b02be0330fd02bb85cd4d44df (diff) | |
fix wrong button style, add new option for popover to better deal with different layouts
Diffstat (limited to 'src/components/popover/popover.js')
| -rw-r--r-- | src/components/popover/popover.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/components/popover/popover.js b/src/components/popover/popover.js index db4a768b..5e417fa0 100644 --- a/src/components/popover/popover.js +++ b/src/components/popover/popover.js @@ -21,7 +21,10 @@ const Popover = { // Replaces the classes you may want for the popover container. // Use 'popover-default' in addition to get the default popover // styles with your custom class. - popoverClass: String + popoverClass: String, + // If true, subtract padding when calculating position for the popover, + // use it when popover offset looks to be different on top vs bottom. + removePadding: Boolean }, data () { return { @@ -96,10 +99,16 @@ const Popover = { if (origin.y + content.offsetHeight > yBounds.max) usingTop = true if (origin.y - content.offsetHeight < yBounds.min) usingTop = false + let vPadding = 0 + if (this.removePadding && usingTop) { + const anchorStyle = getComputedStyle(anchorEl) + vPadding = parseFloat(anchorStyle.paddingTop) + parseFloat(anchorStyle.paddingBottom) + } + const yOffset = (this.offset && this.offset.y) || 0 const translateY = usingTop - ? -anchorEl.offsetHeight - yOffset - content.offsetHeight - : -yOffset + ? -anchorEl.offsetHeight + vPadding - yOffset - content.offsetHeight + : yOffset const xOffset = (this.offset && this.offset.x) || 0 const translateX = (anchorEl.offsetWidth * 0.5) - content.offsetWidth * 0.5 + horizOffset + xOffset |
