From d7b986f3f502e5f7f18bc45ad2af2fd3a77de482 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Thu, 15 Aug 2024 00:26:15 -0400 Subject: [PATCH] fix(graph): update persistent for nodeGfx Signed-off-by: Aaron Pham --- quartz/components/scripts/graph.inline.ts | 60 ++++++++++++----------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/quartz/components/scripts/graph.inline.ts b/quartz/components/scripts/graph.inline.ts index 2773ed95d..127c96864 100644 --- a/quartz/components/scripts/graph.inline.ts +++ b/quartz/components/scripts/graph.inline.ts @@ -362,19 +362,21 @@ async function renderGraph(container: string, fullSlug: FullSlug) { }) .circle(0, 0, nodeRadius(n)) .on("pointerover", () => { - tweens.get(nodeId)?.stop() - const tweenScale = { x: 1, y: 1 } - const tween = new TWEEN.Tween(tweenScale) - .to({ x: 1.5, y: 1.5 }, 100) - .onUpdate(() => { - gfx.scale.set(tweenScale.x, tweenScale.y) - }) - .onStop(() => { - tweens.delete(nodeId) - }) - .start() - tweens.set(nodeId, tween) - renderCurrentNode({ nodeId, focusOnHover }) + if (!currentNodeGfx) { + tweens.get(nodeId)?.stop() + const tweenScale = { x: 1, y: 1 } + const tween = new TWEEN.Tween(tweenScale) + .to({ x: 1.5, y: 1.5 }, 100) + .onUpdate(() => { + gfx.scale.set(tweenScale.x, tweenScale.y) + }) + .onStop(() => { + tweens.delete(nodeId) + }) + .start() + tweens.set(nodeId, tween) + renderCurrentNode({ nodeId, focusOnHover }) + } }) .on("pointerdown", (e) => { currentNodeGfx = e.target as PIXI.Graphics @@ -386,22 +388,24 @@ async function renderGraph(container: string, fullSlug: FullSlug) { currentNodeGfx = undefined }) .on("pointerleave", () => { - tweens.get(nodeId)?.stop() - const tweenScale = { - x: gfx.scale.x, - y: gfx.scale.y, + if (!currentNodeGfx) { + tweens.get(nodeId)?.stop() + const tweenScale = { + x: gfx.scale.x, + y: gfx.scale.y, + } + const tween = new TWEEN.Tween(tweenScale) + .to({ x: 1, y: 1 }, 100) + .onUpdate(() => { + gfx.scale.set(tweenScale.x, tweenScale.y) + }) + .onStop(() => { + tweens.delete(nodeId) + }) + .start() + tweens.set(nodeId, tween) + renderCurrentNode({ nodeId: null, focusOnHover }) } - const tween = new TWEEN.Tween(tweenScale) - .to({ x: 1, y: 1 }, 100) - .onUpdate(() => { - gfx.scale.set(tweenScale.x, tweenScale.y) - }) - .onStop(() => { - tweens.delete(nodeId) - }) - .start() - tweens.set(nodeId, tween) - renderCurrentNode({ nodeId: null, focusOnHover }) }) n.gfx = gfx