Skip to content

Commit fdd4640

Browse files
authored
fix(stage-tamagotchi): override isClickThrough when mouse is in (#482)
1 parent 1b22505 commit fdd4640

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

apps/stage-tamagotchi/src/pages/index.vue

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ const isFirstTime = ref(true)
4646
4747
watchThrottled([mouseX, mouseY], async ([x, y]) => {
4848
const canvas = widgetStageRef.value?.canvasElement()
49-
if (!canvas)
49+
if (!canvas) {
5050
return
51+
}
5152
5253
isFirstTime.value = false
5354
@@ -56,7 +57,6 @@ watchThrottled([mouseX, mouseY], async ([x, y]) => {
5657
passThroughCommands.stopPassThrough()
5758
isPassingThrough.value = false
5859
}
59-
6060
return
6161
}
6262
@@ -66,32 +66,36 @@ watchThrottled([mouseX, mouseY], async ([x, y]) => {
6666
const islandEl = resourceStatusIslandRef.value?.$el as HTMLElement
6767
const buttonsEl = buttonsContainerRef.value
6868
69-
isOverUI.value = false
69+
let isOverUIElements = false
7070
if (!windowControlStore.isIgnoringMouseEvent) {
7171
if (islandEl) {
7272
const rect = islandEl.getBoundingClientRect()
73-
if (relativeX >= rect.left && relativeX <= rect.right && relativeY >= rect.top && relativeY <= rect.bottom)
74-
isOverUI.value = true
73+
if (relativeX >= rect.left && relativeX <= rect.right && relativeY >= rect.top && relativeY <= rect.bottom) {
74+
isOverUIElements = true
75+
}
7576
}
76-
if (!isOverUI.value && buttonsEl) {
77+
if (!isOverUIElements && buttonsEl) {
7778
const rect = buttonsEl.getBoundingClientRect()
78-
if (relativeX >= rect.left && relativeX <= rect.right && relativeY >= rect.top && relativeY <= rect.bottom)
79-
isOverUI.value = true
79+
if (relativeX >= rect.left && relativeX <= rect.right && relativeY >= rect.top && relativeY <= rect.bottom) {
80+
isOverUIElements = true
81+
}
8082
}
83+
}
8184
82-
if (isOverUI.value) {
83-
if (isPassingThrough.value) {
84-
passThroughCommands.stopPassThrough()
85-
isPassingThrough.value = false
86-
}
87-
return
85+
isOverUI.value = isOverUIElements
86+
87+
if (isOverUI.value) {
88+
isClickThrough.value = false
89+
if (isPassingThrough.value) {
90+
passThroughCommands.stopPassThrough()
91+
isPassingThrough.value = false
8892
}
93+
return
8994
}
9095
9196
let isTransparent = false
9297
if (
93-
!isOverUI.value
94-
&& relativeX >= 0
98+
relativeX >= 0
9599
&& relativeX < canvas.clientWidth
96100
&& relativeY >= 0
97101
&& relativeY < canvas.clientHeight
@@ -100,9 +104,8 @@ watchThrottled([mouseX, mouseY], async ([x, y]) => {
100104
if (gl) {
101105
const pixelX = relativeX * (gl.drawingBufferWidth / canvas.clientWidth)
102106
const pixelY
103-
= gl.drawingBufferHeight
104-
- relativeY * (gl.drawingBufferHeight / canvas.clientHeight)
105-
107+
= gl.drawingBufferHeight
108+
- relativeY * (gl.drawingBufferHeight / canvas.clientHeight)
106109
const data = new Uint8Array(4)
107110
gl.readPixels(
108111
Math.floor(pixelX),
@@ -239,7 +242,6 @@ if (import.meta.hot) { // For better DX
239242
<div
240243
:class="[modeIndicatorClass, {
241244
'op-0': windowControlStore.isIgnoringMouseEvent && !isClickThrough && !isFirstTime,
242-
'pointer-events-none': !isClickThrough,
243245
}]"
244246
max-h="[100vh]"
245247
max-w="[100vw]"
@@ -284,9 +286,7 @@ if (import.meta.hot) { // For better DX
284286
</div>
285287
</div>
286288
</div>
287-
<!-- Debug Mode UI -->
288289
<div v-if="windowControlStore.controlMode === WindowControlMode.DEBUG" class="debug-controls">
289-
<!-- Add debug controls here -->
290290
</div>
291291
</div>
292292
<Transition

0 commit comments

Comments
 (0)