fix(tooltip): fix tooltip position with scroll height and scroll width
This commit is contained in:
parent
1a7999ea58
commit
3f71272584
|
@ -13,6 +13,8 @@ export function useTooltipPosition(
|
|||
|
||||
const rectifyGutter = 20;
|
||||
|
||||
const { scrollLeft, scrollTop } = document.documentElement;
|
||||
|
||||
const revertDirectionMap = new Map<RectDirection, RectDirection>(
|
||||
[['top', 'bottom'], ['bottom', 'top'], ['left', 'right'], ['right', 'left']]
|
||||
);
|
||||
|
@ -185,12 +187,12 @@ export function useTooltipPosition(
|
|||
tooltipBound,
|
||||
tooltipBound
|
||||
);
|
||||
return { top, left, right };
|
||||
return { top: top + scrollTop, left: left + scrollLeft, right };
|
||||
});
|
||||
|
||||
const arrowPosition = computed<RectPosition>(() => {
|
||||
const { top, left, right } = calculateArrowPosition(placement.value, hostBound, tooltipPosition.value, arrowBound);
|
||||
return { top, left, right };
|
||||
return { top: top + scrollTop, left: left + scrollLeft, right };
|
||||
});
|
||||
|
||||
return { arrowPosition, tooltipPlacement, tooltipPosition };
|
||||
|
|
|
@ -36,8 +36,7 @@ export default defineComponent({
|
|||
const tooltipStyle = computed(() => {
|
||||
const styleObject = {
|
||||
left: tooltipLeftPosition.value,
|
||||
top: tooltipTopPosition.value,
|
||||
right: tooltipRightPosition.value
|
||||
top: tooltipTopPosition.value
|
||||
};
|
||||
return styleObject;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue