Watching clientX/clientY values as PROPS only work when mouse moves alongside the x-achsis #11934
-
Im using <script setup> with Vue 3 with Typescript My parentComponent ButtonWrapper.vue contains two PrimButton.vue Components. Depending on the mousemovement within ButtonWrapper.vue i am going to manipulate the Background-images of my PrimButtons. For that i need to identify the mouseposition when moving the mouse over ButtonWrapper. ButtonWrapper.vue:
PrimButton.vue:
What is confusing is the fact that as long as i move my mouse alongside the x achsis, it works: But as soon as i move the mouse alongside the y achsis, both values become undefined: Why is that? What did i do wrong? EDIT: I just corrected the wrong syntax in the callbackfunction in the watch function. But still with the same result, only that, when i move alongside the x axis, the values for cy are undefined and if i move alongside the y axis, vice versa: EDIT2": I switched to using Provide/Inject but just to be able to keep working. It should also be possible to do that with props, dont you think? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You are misreading your own console logs.
|
Beta Was this translation helpful? Give feedback.
You are misreading your own console logs.
console.clear()
cx
(socy
is undefined), one receivescy
(socx
is undefined)cx
changes, so only the button receivingcx
will update, and log what you see on your screenshot -cy
being undefined because you never passed a value to that button.cy
value and thus updates, but it doesn't receivecx
, so it's undefined.