Fix graphs tooltip incorrect position (#1872)

This commit is contained in:
BlueGreenMagick 2022-05-19 10:08:57 +09:00 committed by GitHub
parent 638286a3fc
commit 6ddbf7bc10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,8 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { tick } from "svelte";
export let html = "";
export let x: number = 0;
export let y: number = 0;
@ -13,9 +15,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let adjustedX: number, adjustedY: number;
let shiftLeftAmount = 0;
$: shiftLeftAmount = container
? Math.round(container.clientWidth * 1.2 * (x / document.body.clientWidth))
: 0;
$: onXChange(x);
async function onXChange(xPos: number) {
await tick();
shiftLeftAmount = container
? Math.round(
container.clientWidth * 1.2 * (xPos / document.body.clientWidth),
)
: 0;
}
$: {
// move tooltip away from edge as user approaches right side
@ -35,6 +44,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<style lang="scss">
.tooltip {
position: absolute;
white-space: nowrap;
padding: 15px;
border-radius: 5px;
font-size: 15px;