mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
chore: tooltip placing
This commit is contained in:
@@ -29,7 +29,7 @@ export default defineComponent({
|
||||
border-radius: 0.25em;
|
||||
|
||||
width: 100%;
|
||||
background-color: #333;
|
||||
background-color: #1f1f1f;
|
||||
box-shadow: 0 0 5px 2px #aaa;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ import BaseTooltip from './BaseTooltip.vue';
|
||||
import SpawnsTooltip from './SpawnsTooltip.vue';
|
||||
import UsersTooltip from './UsersTooltip.vue';
|
||||
|
||||
const BOX_PADDING_PX = 20;
|
||||
|
||||
export default defineComponent({
|
||||
components: { DonatorTooltip, VehiclePreviewTooltip, BaseTooltip, SpawnsTooltip, UsersTooltip },
|
||||
|
||||
@@ -33,14 +35,14 @@ export default defineComponent({
|
||||
const boxWidth = previewEl.getBoundingClientRect().width;
|
||||
|
||||
let translateX = '0',
|
||||
translateY = '30px';
|
||||
translateY = `calc(-100% - ${BOX_PADDING_PX}px)`;
|
||||
|
||||
if (val[0] <= boxWidth / 2) {
|
||||
if (val[0] <= boxWidth / 2 + BOX_PADDING_PX) {
|
||||
previewEl.style.left = '0';
|
||||
translateX = '0px';
|
||||
} else if (val[0] >= clientWidth - boxWidth / 2) {
|
||||
translateX = BOX_PADDING_PX + 'px';
|
||||
} else if (val[0] >= clientWidth - boxWidth / 2 - BOX_PADDING_PX) {
|
||||
previewEl.style.left = '100%';
|
||||
translateX = '-100%';
|
||||
translateX = `calc(-100% - ${BOX_PADDING_PX}px)`;
|
||||
} else {
|
||||
previewEl.style.left = `${val[0]}px`;
|
||||
translateX = '-50%';
|
||||
@@ -49,10 +51,10 @@ export default defineComponent({
|
||||
previewEl.style.top = `${val[1]}px`;
|
||||
|
||||
const isOutside =
|
||||
val[1] + previewEl.getBoundingClientRect().height + 30 >=
|
||||
window.innerHeight + window.scrollY;
|
||||
val[1] - previewEl.getBoundingClientRect().height <=
|
||||
window.scrollY + BOX_PADDING_PX * 2;
|
||||
|
||||
if (isOutside) translateY = 'calc(-100% - 30px)';
|
||||
if (isOutside) translateY = BOX_PADDING_PX + 'px';
|
||||
previewEl.style.transform = `translate(${translateX}, ${translateY})`;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ export default defineComponent({
|
||||
.tooltip-content {
|
||||
width: 300px;
|
||||
min-height: 200px;
|
||||
background-color: #333;
|
||||
background-color: #1f1f1f;
|
||||
box-shadow: 0 0 10px 2px #aaa;
|
||||
|
||||
padding: 0.5em;
|
||||
|
||||
Reference in New Issue
Block a user