From fdd46408e10d3a041d5c094618c7fab5eaa25362 Mon Sep 17 00:00:00 2001 From: hobbycoder <168180007+gg582@users.noreply.github.com> Date: Thu, 28 Aug 2025 04:11:38 +0000 Subject: [PATCH] fix(stage-tamagotchi): override `isClickThrough` when mouse is in (#482) --- apps/stage-tamagotchi/src/pages/index.vue | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/stage-tamagotchi/src/pages/index.vue b/apps/stage-tamagotchi/src/pages/index.vue index 5cef3d382..bac5c681f 100644 --- a/apps/stage-tamagotchi/src/pages/index.vue +++ b/apps/stage-tamagotchi/src/pages/index.vue @@ -46,8 +46,9 @@ const isFirstTime = ref(true) watchThrottled([mouseX, mouseY], async ([x, y]) => { const canvas = widgetStageRef.value?.canvasElement() - if (!canvas) + if (!canvas) { return + } isFirstTime.value = false @@ -56,7 +57,6 @@ watchThrottled([mouseX, mouseY], async ([x, y]) => { passThroughCommands.stopPassThrough() isPassingThrough.value = false } - return } @@ -66,32 +66,36 @@ watchThrottled([mouseX, mouseY], async ([x, y]) => { const islandEl = resourceStatusIslandRef.value?.$el as HTMLElement const buttonsEl = buttonsContainerRef.value - isOverUI.value = false + let isOverUIElements = false if (!windowControlStore.isIgnoringMouseEvent) { if (islandEl) { const rect = islandEl.getBoundingClientRect() - if (relativeX >= rect.left && relativeX <= rect.right && relativeY >= rect.top && relativeY <= rect.bottom) - isOverUI.value = true - } - if (!isOverUI.value && buttonsEl) { - const rect = buttonsEl.getBoundingClientRect() - if (relativeX >= rect.left && relativeX <= rect.right && relativeY >= rect.top && relativeY <= rect.bottom) - isOverUI.value = true - } - - if (isOverUI.value) { - if (isPassingThrough.value) { - passThroughCommands.stopPassThrough() - isPassingThrough.value = false + if (relativeX >= rect.left && relativeX <= rect.right && relativeY >= rect.top && relativeY <= rect.bottom) { + isOverUIElements = true } - return } + if (!isOverUIElements && buttonsEl) { + const rect = buttonsEl.getBoundingClientRect() + if (relativeX >= rect.left && relativeX <= rect.right && relativeY >= rect.top && relativeY <= rect.bottom) { + isOverUIElements = true + } + } + } + + isOverUI.value = isOverUIElements + + if (isOverUI.value) { + isClickThrough.value = false + if (isPassingThrough.value) { + passThroughCommands.stopPassThrough() + isPassingThrough.value = false + } + return } let isTransparent = false if ( - !isOverUI.value - && relativeX >= 0 + relativeX >= 0 && relativeX < canvas.clientWidth && relativeY >= 0 && relativeY < canvas.clientHeight @@ -100,9 +104,8 @@ watchThrottled([mouseX, mouseY], async ([x, y]) => { if (gl) { const pixelX = relativeX * (gl.drawingBufferWidth / canvas.clientWidth) const pixelY - = gl.drawingBufferHeight - - relativeY * (gl.drawingBufferHeight / canvas.clientHeight) - + = gl.drawingBufferHeight + - relativeY * (gl.drawingBufferHeight / canvas.clientHeight) const data = new Uint8Array(4) gl.readPixels( Math.floor(pixelX), @@ -239,7 +242,6 @@ if (import.meta.hot) { // For better DX
-
-