fix animations, replace ugly old mentionlink tooltips with new usercard ones
This commit is contained in:
parent
61d63b0e61
commit
55adcd822e
8 changed files with 140 additions and 90 deletions
|
|
@ -31,13 +31,18 @@ const Popover = {
|
|||
|
||||
// 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
|
||||
removePadding: Boolean,
|
||||
|
||||
// self-explanatory (i hope)
|
||||
disabled: Boolean
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
hidden: true,
|
||||
styles: { opacity: 0 },
|
||||
oldSize: { width: 0, height: 0 }
|
||||
styles: {},
|
||||
oldSize: { width: 0, height: 0 },
|
||||
// used to avoid blinking if hovered onto popover
|
||||
graceTimeout: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -47,9 +52,7 @@ const Popover = {
|
|||
},
|
||||
updateStyles () {
|
||||
if (this.hidden) {
|
||||
this.styles = {
|
||||
opacity: 0
|
||||
}
|
||||
this.styles = {}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +135,6 @@ const Popover = {
|
|||
// Note, separate translateX and translateY avoids blurry text on chromium,
|
||||
// single translate or translate3d resulted in blurry text.
|
||||
this.styles = {
|
||||
opacity: 1,
|
||||
left: `${Math.round(translateX)}px`,
|
||||
top: `${Math.round(translateY)}px`,
|
||||
position: 'fixed'
|
||||
|
|
@ -143,6 +145,7 @@ const Popover = {
|
|||
}
|
||||
},
|
||||
showPopover () {
|
||||
if (this.disabled) return
|
||||
const wasHidden = this.hidden
|
||||
this.hidden = false
|
||||
this.$nextTick(() => {
|
||||
|
|
@ -153,13 +156,30 @@ const Popover = {
|
|||
hidePopover () {
|
||||
if (!this.hidden) this.$emit('close')
|
||||
this.hidden = true
|
||||
this.styles = { opacity: 0 }
|
||||
},
|
||||
onMouseenter (e) {
|
||||
if (this.trigger === 'hover') this.showPopover()
|
||||
if (this.trigger === 'hover') {
|
||||
clearTimeout(this.graceTimeout)
|
||||
this.graceTimeout = null
|
||||
this.showPopover()
|
||||
}
|
||||
},
|
||||
onMouseleave (e) {
|
||||
if (this.trigger === 'hover') this.hidePopover()
|
||||
if (this.trigger === 'hover') {
|
||||
this.graceTimeout = setTimeout(() => this.hidePopover(), 1)
|
||||
}
|
||||
},
|
||||
onMouseenterContent (e) {
|
||||
if (this.trigger === 'hover') {
|
||||
clearTimeout(this.graceTimeout)
|
||||
this.graceTimeout = null
|
||||
this.showPopover()
|
||||
}
|
||||
},
|
||||
onMouseleaveContent (e) {
|
||||
if (this.trigger === 'hover') {
|
||||
this.graceTimeout = setTimeout(() => this.hidePopover(), 1)
|
||||
}
|
||||
},
|
||||
onClick (e) {
|
||||
if (this.trigger === 'click') {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div
|
||||
<span
|
||||
@mouseenter="onMouseenter"
|
||||
@mouseleave="onMouseleave"
|
||||
>
|
||||
|
|
@ -12,21 +12,25 @@
|
|||
<slot name="trigger" />
|
||||
</button>
|
||||
<teleport to="#popovers">
|
||||
<div
|
||||
v-if="!hidden"
|
||||
ref="content"
|
||||
:style="styles"
|
||||
class="popover"
|
||||
:class="popoverClass || 'popover-default'"
|
||||
>
|
||||
<slot
|
||||
name="content"
|
||||
class="popover-inner"
|
||||
:close="hidePopover"
|
||||
/>
|
||||
</div>
|
||||
<transition name="fade">
|
||||
<div
|
||||
v-if="!hidden"
|
||||
ref="content"
|
||||
:style="styles"
|
||||
class="popover"
|
||||
:class="popoverClass || 'popover-default'"
|
||||
@mouseenter="onMouseenterContent"
|
||||
@mouseleave="onMouseleaveContent"
|
||||
>
|
||||
<slot
|
||||
name="content"
|
||||
class="popover-inner"
|
||||
:close="hidePopover"
|
||||
/>
|
||||
</div>
|
||||
</transition>
|
||||
</teleport>
|
||||
</div>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script src="./popover.js" />
|
||||
|
|
@ -47,8 +51,6 @@
|
|||
}
|
||||
|
||||
.popover-default {
|
||||
transition: opacity 0.3s;
|
||||
|
||||
&:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue