diff options
| author | Henry Jameson <me@hjkos.com> | 2022-08-30 23:54:16 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-08-30 23:54:16 +0300 |
| commit | 887fac5addc2416504593cb62a52a3b08f3638e2 (patch) | |
| tree | 74711c1bc7ec9fe991ad15d51b3ecfab7e5e0749 /src/components/popover/popover.js | |
| parent | af734afe3694ff3c77d4457b93b02309c4f55d6d (diff) | |
| parent | 8b25febe36a97d113c846928dab22ab36158ee07 (diff) | |
Merge remote-tracking branch 'origin/develop' into scrolltotop
* origin/develop: (59 commits)
a11y
Use dedicated indicator for non-ascii domain names
add a favorites "timeline" shortcut
refactor navigation-entry and use them in other nav items
Update dependency sinon-chai to v3
Update dependency semver to v7
Update dependency vue-router to v4.1.5
Update dependency eslint to v8.23.0
Update dependency vue-template-compiler to v2.7.10
Update dependency @vue/babel-helper-vue-jsx-merge-props to v1.4.0
Update dependency eslint-plugin-promise to v6.0.1
fix lists edit page
change ugly checkbox to a list element that doesn't look too much out of place
a11y
squeeze/stretch pinned items as long as there's enough space for it, hide items that won't fitc
Remove isparta
lint
fix being unable to edit timeline pins on mobile
aria
fix mobile side drawer causing issues
...
Diffstat (limited to 'src/components/popover/popover.js')
| -rw-r--r-- | src/components/popover/popover.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/components/popover/popover.js b/src/components/popover/popover.js index d2af59fe..dd332c35 100644 --- a/src/components/popover/popover.js +++ b/src/components/popover/popover.js @@ -4,7 +4,7 @@ const Popover = { // Action to trigger popover: either 'hover' or 'click' trigger: String, - // Either 'top' or 'bottom' + // 'top', 'bottom', 'left', 'right' placement: String, // Takes object with properties 'x' and 'y', values of these can be @@ -84,6 +84,8 @@ const Popover = { const anchorStyle = getComputedStyle(anchorEl) const topPadding = parseFloat(anchorStyle.paddingTop) const bottomPadding = parseFloat(anchorStyle.paddingBottom) + const rightPadding = parseFloat(anchorStyle.paddingRight) + const leftPadding = parseFloat(anchorStyle.paddingLeft) // Screen position of the origin point for popover = center of the anchor const origin = { @@ -170,7 +172,7 @@ const Popover = { if (overlayCenter) { translateX = origin.x + horizOffset translateY = origin.y + vertOffset - } else { + } else if (this.placement !== 'right' && this.placement !== 'left') { // Default to whatever user wished with placement prop let usingTop = this.placement !== 'bottom' @@ -189,6 +191,25 @@ const Popover = { const xOffset = (this.offset && this.offset.x) || 0 translateX = origin.x + horizOffset + xOffset + } else { + // Default to whatever user wished with placement prop + let usingRight = this.placement !== 'left' + + // Handle special cases, first force to displaying on top if there's not space on bottom, + // regardless of what placement value was. Then check if there's not space on top, and + // force to bottom, again regardless of what placement value was. + const rightBoundary = origin.x - anchorWidth * 0.5 + (this.removePadding ? rightPadding : 0) + const leftBoundary = origin.x + anchorWidth * 0.5 - (this.removePadding ? leftPadding : 0) + if (leftBoundary + content.offsetWidth > xBounds.max) usingRight = true + if (rightBoundary - content.offsetWidth < xBounds.min) usingRight = false + + const xOffset = (this.offset && this.offset.x) || 0 + translateX = usingRight + ? rightBoundary - xOffset - content.offsetWidth + : leftBoundary + xOffset + + const yOffset = (this.offset && this.offset.y) || 0 + translateY = origin.y + vertOffset + yOffset } this.styles = { |
