vueuse / vueuse

Collection of essential Vue Composition Utilities for Vue 2 and 3
https://vueuse.org
MIT License
19.8k stars 2.51k forks source link

useMouseInElement Returns isOutside: true When Scrolling in Nuxt3 #4186

Open lhoucinecherif opened 4 weeks ago

lhoucinecherif commented 4 weeks ago

Describe the bug

I'm experiencing an issue with the useMouseInElement function from VueUse in a Nuxt3 project. The isOutside value always returns true when I scroll the page whithout moving the mouse, even if the mouse is inside the element.

Reproduction

https://stackblitz.com/edit/vitejs-vite-iwn1w4?file=src%2FApp.vue

System Info

System:
    OS: Linux 6.8 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (16) x64 Intel(R) Xeon(R) CPU           E5640  @ 2.67GHz
    Memory: 11.56 GB / 23.49 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.15.0/bin/yarn
    npm: 10.8.1 - ~/.nvm/versions/node/v20.15.0/bin/npm
    pnpm: 9.4.0 - ~/.local/share/pnpm/pnpm
  Browsers:
    Chrome: 126.0.6478.126
  npmPackages:
    @vueuse/components: ^11.0.3 => 11.0.3 
    @vueuse/nuxt: ^10.11.1 => 10.11.1

Used Package Manager

pnpm

Validations

mickaelchanrion commented 2 weeks ago

Hey there 👋

I noticed this strange behavior too while using useMouseInElement with type page. It is also visible in the demo here.

If I scroll without moving the mouse, not only isOutside but also y and elementY get off. I guess it would be the same for x values in case the page was with a horizontal scroll.

https://github.com/user-attachments/assets/ac78ea27-8d14-486a-b19e-588a9c3cc07b

I could see that this composable uses useMouse under the hood and the demo has the same behavior so the culprit is this composable.

https://github.com/user-attachments/assets/f12ebf1c-a336-40f3-961f-7f652bcc6189