fix centering of certain dropdowns
This commit is contained in:
parent
0723c07571
commit
813d121cdd
3 changed files with 12 additions and 15 deletions
|
@ -47,12 +47,10 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<i
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
class="button-icon"
|
class="icon-ellipsis button-icon"
|
||||||
>
|
/>
|
||||||
<i class="icon-ellipsis" />
|
|
||||||
</div>
|
|
||||||
</Popover>
|
</Popover>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,9 @@ const Popover = {
|
||||||
updateStyles () {
|
updateStyles () {
|
||||||
if (this.hidden) return { opacity: 0 }
|
if (this.hidden) return { opacity: 0 }
|
||||||
|
|
||||||
// Popover will be anchored around this element
|
// Popover will be anchored around this element, trigger ref is the container, so
|
||||||
const anchorEl = this.$refs.trigger || this.$el
|
// its children are what are inside the slot. Expect only one slot="trigger".
|
||||||
|
const anchorEl = (this.$refs.trigger && this.$refs.trigger.children[0]) || this.$el
|
||||||
const screenBox = anchorEl.getBoundingClientRect()
|
const screenBox = anchorEl.getBoundingClientRect()
|
||||||
// Screen position of the origin point for popover
|
// Screen position of the origin point for popover
|
||||||
const origin = { x: screenBox.left + screenBox.width * 0.5, y: screenBox.top }
|
const origin = { x: screenBox.left + screenBox.width * 0.5, y: screenBox.top }
|
||||||
|
@ -86,7 +87,7 @@ const Popover = {
|
||||||
|
|
||||||
this.styles = {
|
this.styles = {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
transform: `translate(${Math.floor(translateX)}px, ${Math.floor(translateY)}px)`
|
transform: `translate(${Math.floor(translateX)}px) translateY(${Math.floor(translateY)}px)`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showPopover () {
|
showPopover () {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Popover
|
<Popover
|
||||||
trigger="click"
|
trigger="click"
|
||||||
placement="top"
|
placement="top"
|
||||||
|
:offset="{ y: 5 }"
|
||||||
class="react-button-popover"
|
class="react-button-popover"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -35,15 +36,12 @@
|
||||||
<div class="reaction-bottom-fader" />
|
<div class="reaction-bottom-fader" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<i
|
||||||
v-if="loggedIn"
|
v-if="loggedIn"
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="icon-smile button-icon add-reaction-button"
|
class="icon-smile button-icon add-reaction-button"
|
||||||
:title="$t('tool_tip.add_reaction')"
|
:title="$t('tool_tip.add_reaction')"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</Popover>
|
</Popover>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue