fix(graph): update persistent for nodeGfx

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham 2024-08-15 00:26:15 -04:00
parent e00c1ac491
commit d7b986f3f5
No known key found for this signature in database
GPG Key ID: 18974753009D2BFA

View File

@ -362,19 +362,21 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
}) })
.circle(0, 0, nodeRadius(n)) .circle(0, 0, nodeRadius(n))
.on("pointerover", () => { .on("pointerover", () => {
tweens.get(nodeId)?.stop() if (!currentNodeGfx) {
const tweenScale = { x: 1, y: 1 } tweens.get(nodeId)?.stop()
const tween = new TWEEN.Tween(tweenScale) const tweenScale = { x: 1, y: 1 }
.to({ x: 1.5, y: 1.5 }, 100) const tween = new TWEEN.Tween(tweenScale)
.onUpdate(() => { .to({ x: 1.5, y: 1.5 }, 100)
gfx.scale.set(tweenScale.x, tweenScale.y) .onUpdate(() => {
}) gfx.scale.set(tweenScale.x, tweenScale.y)
.onStop(() => { })
tweens.delete(nodeId) .onStop(() => {
}) tweens.delete(nodeId)
.start() })
tweens.set(nodeId, tween) .start()
renderCurrentNode({ nodeId, focusOnHover }) tweens.set(nodeId, tween)
renderCurrentNode({ nodeId, focusOnHover })
}
}) })
.on("pointerdown", (e) => { .on("pointerdown", (e) => {
currentNodeGfx = e.target as PIXI.Graphics currentNodeGfx = e.target as PIXI.Graphics
@ -386,22 +388,24 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
currentNodeGfx = undefined currentNodeGfx = undefined
}) })
.on("pointerleave", () => { .on("pointerleave", () => {
tweens.get(nodeId)?.stop() if (!currentNodeGfx) {
const tweenScale = { tweens.get(nodeId)?.stop()
x: gfx.scale.x, const tweenScale = {
y: gfx.scale.y, 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 n.gfx = gfx