diff options
| author | Shpuld Shpludson <shp@cock.li> | 2020-12-22 16:00:12 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2020-12-22 16:00:12 +0000 |
| commit | a39866308cd7c8cb0d30a04a5215d1fae8bf8d47 (patch) | |
| tree | 59230ab336bf3bd13f0d046c6f45842a7fbdd02c /src/components/popover/popover.js | |
| parent | a7567ce6d01781b4b1ff47f805b4a9a5109e960b (diff) | |
| parent | 00cb8d9dcee9a403fedb2800a0cdc4b0f77a0429 (diff) | |
Merge branch 'rc/2.2.2' into 'master'
prepare master for 2.2.2
See merge request pleroma/pleroma-fe!1315
Diffstat (limited to 'src/components/popover/popover.js')
| -rw-r--r-- | src/components/popover/popover.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/components/popover/popover.js b/src/components/popover/popover.js index 695f73b9..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,9 +99,15 @@ 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 + ? -anchorEl.offsetHeight + vPadding - yOffset - content.offsetHeight : yOffset const xOffset = (this.offset && this.offset.x) || 0 |
