Skip to content

Commit

Permalink
Merge branch 'main' into 170-add-full-name-to-acronyms-in-help
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobTopholt committed May 28, 2024
2 parents 3807f37 + 69e3dcb commit 05c5e2e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib/components/Packet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
let transitionDuration: number;
let animation: Animation | undefined;
let packetElement: SVGElement | undefined;
let textX: number = 0;
let textY: number = 0;
$: {
if (animation) {
requestAnimationFrame(() => {
if (packetElement) {
const matrix = new DOMMatrixReadOnly(getComputedStyle(packetElement).transform);
textX = matrix.m41;
textY = matrix.m42;
}
if ($config.running) {
animation?.play();
} else {
Expand Down Expand Up @@ -77,13 +84,28 @@
</script>

<circle class:labeled={packet.label !== -1} bind:this={packetElement} r="5" />
{#if packetElement}
<text x={textX - 50} y={textY - 15}>Label: {packet.label}</text>
{/if}

<style>
circle {
cursor: default;
fill: #da443f; /*weird red*/
}
.labeled {
fill: #6495ed; /*light blue*/
}
text {
font-size: 24px;
fill: white;
stroke: black;
display: none;
}
circle:hover + text {
display: block;
}
</style>

0 comments on commit 05c5e2e

Please sign in to comment.