添加鼠标提示的自动关闭功能

This commit is contained in:
lyswhut
2021-01-03 00:46:13 +08:00
parent 0f71a93c5e
commit 06073f3982
4 changed files with 29 additions and 4 deletions
+7 -3
View File
@@ -19,18 +19,22 @@ const showTips = debounce(event => {
prevTips = msg
instance = tips({
message: msg,
autoCloseTime: 10000,
position: {
top: event.y + 12,
left: event.x + 8,
},
})
instance.$on('beforeClose', closeInstance => {
if (instance !== closeInstance) return
prevTips = null
instance = null
})
}, 400)
const hideTips = () => {
if (!instance) return
instance.cancel()
prevTips = null
instance = null
}
const setTips = tips => {
@@ -39,7 +43,7 @@ const setTips = tips => {
}
const updateTips = event => {
if (!instance) return
if (!instance) return showTips(event)
setTimeout(() => {
let msg = getTips(event.target)
if (!msg || prevTips === msg) return