fix(tooltip): fix auto adapt popup direction
This commit is contained in:
parent
64fba0d1bb
commit
a26a610e4e
|
@ -216,15 +216,15 @@ export function useTooltipPosition(
|
|||
}
|
||||
|
||||
const tooltipPlacement = computed<TooltipPlacement>(() => {
|
||||
// const rectifyPlacement = autoRectifyDirection(placement.value, hostBound, hostBound, tooltipBound, arrowBound);
|
||||
return placement.value;
|
||||
});
|
||||
|
||||
const tooltipPosition = computed<RectPosition>(() => {
|
||||
const referenceBound = getReferenceBound();
|
||||
placement.value = autoRectifyDirection(placement.value, referenceBound, hostBound, tooltipBound, arrowBound);
|
||||
const originalTop = calculateTooltipTopPositoin(placement.value, hostBound, tooltipBound, arrowBound);
|
||||
const originalLeft = calculateTooltipLeftPosition(placement.value, hostBound, tooltipBound, arrowBound);
|
||||
const originalRight = calculateTooltipRightPosition(placement.value, hostBound, tooltipBound, arrowBound);
|
||||
const referenceBound = getReferenceBound();
|
||||
const { top, left, right } = tryFixOverBound(
|
||||
placement.value,
|
||||
{ top: originalTop, left: originalLeft, right: originalRight },
|
||||
|
|
|
@ -64,13 +64,12 @@ export default defineComponent({
|
|||
tooltipRef.value.getBoundingClientRect(),
|
||||
arrowRef.value.getBoundingClientRect()
|
||||
);
|
||||
placement.value = tooltipPlacement.value;
|
||||
arrowLeftPosition.value = `${arrowPosition.value.left}px`;
|
||||
arrowTopPosition.value = `${arrowPosition.value.top}px`;
|
||||
tooltipLeftPosition.value = `${tooltipPosition.value.left}px`;
|
||||
tooltipRightPosition.value = `${tooltipPosition.value.right}px`;
|
||||
tooltipTopPosition.value = `${tooltipPosition.value.top}px`;
|
||||
|
||||
arrowLeftPosition.value = `${arrowPosition.value.left}px`;
|
||||
arrowTopPosition.value = `${arrowPosition.value.top}px`;
|
||||
placement.value = tooltipPlacement.value;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -8,5 +8,5 @@ const tooltipProps = { placement: 'bottom' };
|
|||
<template>
|
||||
<Tooltip> </Tooltip>
|
||||
|
||||
<Button v-tooltip="{ placement: 'bottom' }"> 显示提示信息 </Button>
|
||||
<Button v-tooltip="{ placement: 'right' }"> 显示提示信息 </Button>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue