Skip to content

Commit 884b632

Browse files
committed
Atom - Tooltip - Add prop to optionally prevent Y shifting
1 parent f4fa007 commit 884b632

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/atoms/Tooltip.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ const props = defineProps({
5656
offsetY: {
5757
type: Number,
5858
default: 24
59+
},
60+
blockShiftY: {
61+
type: Boolean,
62+
default: false,
5963
}
6064
});
6165
@@ -69,7 +73,8 @@ const position = computed(() => {
6973
chart: props.parent,
7074
clientPosition: clientPosition.value,
7175
positionPreference: props.position,
72-
defaultOffsetY: props.offsetY
76+
defaultOffsetY: props.offsetY,
77+
blockShiftY: props.blockShiftY
7378
});
7479
})
7580

src/calcTooltipPosition.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ref } from "vue";
22

3-
export function calcTooltipPosition({ tooltip, chart, clientPosition, positionPreference = 'center', defaultOffsetY = 24}) {
3+
export function calcTooltipPosition({ tooltip, chart, clientPosition, positionPreference = 'center', defaultOffsetY = 24, blockShiftY = false}) {
44
const offsetX = ref(0);
55
const offsetY = ref(defaultOffsetY);
66
if (tooltip && chart) {
@@ -33,7 +33,7 @@ export function calcTooltipPosition({ tooltip, chart, clientPosition, positionPr
3333
}
3434
}
3535

36-
if (clientPosition.y + height > bottom) {
36+
if (clientPosition.y + height > bottom && !blockShiftY) {
3737
offsetY.value = -height - defaultOffsetY;
3838
}
3939
}

0 commit comments

Comments
 (0)