|
@@ -1,5 +1,5 @@
|
|
|
// 引入组件
|
|
|
-import {createApp, nextTick} from "vue";
|
|
|
+import { createApp, nextTick } from "vue"
|
|
|
import MyToolTip from './ToolTip.vue'
|
|
|
|
|
|
/**
|
|
@@ -9,15 +9,15 @@ import MyToolTip from './ToolTip.vue'
|
|
|
// 位置定位
|
|
|
function calculationLocation(el, target, placements) {
|
|
|
if (!el || !target) return;
|
|
|
- console.log('el:', el)
|
|
|
- console.log('target:', target)
|
|
|
+ // console.log('el:', el)
|
|
|
+ // console.log('target:', target)
|
|
|
|
|
|
el.tooltipPosition.y = 0;
|
|
|
el.tooltipPosition.x = 0;
|
|
|
let el_dom = el.$el?.nextElementSibling?.getBoundingClientRect() || target?.w_tipInstance?.$el?.nextElementSibling?.getBoundingClientRect() || null
|
|
|
let target_dom = target.getBoundingClientRect()
|
|
|
if(!el_dom) {
|
|
|
- console.log('el_dom:不存在', el_dom)
|
|
|
+ // console.log('el_dom:不存在', el_dom)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -53,18 +53,23 @@ function getElStyleAttr(element, attr) {
|
|
|
// }
|
|
|
|
|
|
const isOverflow = (target) => {
|
|
|
- const scrollWidth = target.scrollWidth
|
|
|
- const offsetWidth = target.offsetWidth
|
|
|
- const range = document.createRange()
|
|
|
- range.setStart(target, 0)
|
|
|
- range.setEnd(target, target.childNodes.length)
|
|
|
- const rangeWidth = range.getBoundingClientRect().width
|
|
|
- const padding = (parseInt(getElStyleAttr(target, 'paddingLeft'), 10) || 0) + (parseInt(getElStyleAttr(target, 'paddingRight'), 10) || 0)
|
|
|
- return (rangeWidth + padding > target.offsetWidth) || scrollWidth > offsetWidth
|
|
|
+ // const scrollWidth = target.scrollWidth
|
|
|
+ // const offsetWidth = target.offsetWidth
|
|
|
+ // const range = document.createRange()
|
|
|
+ // range.setStart(target, 0)
|
|
|
+ // range.setEnd(target, target.childNodes.length)
|
|
|
+ // const rangeWidth = range.getBoundingClientRect().width
|
|
|
+ // const padding = (parseInt(getElStyleAttr(target, 'paddingLeft'), 10) || 0) + (parseInt(getElStyleAttr(target, 'paddingRight'), 10) || 0)
|
|
|
+ // return (rangeWidth + padding > target.offsetWidth) || scrollWidth > offsetWidth
|
|
|
+
|
|
|
// return scrollWidth > offsetWidth
|
|
|
+
|
|
|
+ const scrollWidth = target.scrollWidth
|
|
|
+ const clientWidth = target.clientWidth
|
|
|
+ return scrollWidth > clientWidth
|
|
|
}
|
|
|
|
|
|
-export const ellipsisTooltip = localStorage.getItem('useEllipseTooltip') ? {
|
|
|
+export const ellipsisTooltip = {
|
|
|
mounted(el, binding) {
|
|
|
//获取指令的参数
|
|
|
const {
|
|
@@ -129,5 +134,5 @@ export const ellipsisTooltip = localStorage.getItem('useEllipseTooltip') ? {
|
|
|
}
|
|
|
window.removeEventListener('scroll', el._scrollHandler)
|
|
|
}
|
|
|
-} : {}
|
|
|
+}
|
|
|
|