mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Fix graphs tooltip incorrect position (#1872)
This commit is contained in:
parent
638286a3fc
commit
6ddbf7bc10
1 changed files with 13 additions and 3 deletions
|
@ -3,6 +3,8 @@ Copyright: Ankitects Pty Ltd and contributors
|
||||||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { tick } from "svelte";
|
||||||
|
|
||||||
export let html = "";
|
export let html = "";
|
||||||
export let x: number = 0;
|
export let x: number = 0;
|
||||||
export let y: 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 adjustedX: number, adjustedY: number;
|
||||||
|
|
||||||
let shiftLeftAmount = 0;
|
let shiftLeftAmount = 0;
|
||||||
$: shiftLeftAmount = container
|
$: onXChange(x);
|
||||||
? Math.round(container.clientWidth * 1.2 * (x / document.body.clientWidth))
|
|
||||||
: 0;
|
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
|
// 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">
|
<style lang="scss">
|
||||||
.tooltip {
|
.tooltip {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
white-space: nowrap;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
|
Loading…
Reference in a new issue