Skip to content

useMouseInElement is not updating correctly on scroll for static element #2922

@jbreuil

Description

@jbreuil

Describe the bug

While useMouse is totally correct to not update x or y value on scroll, this is not what should happen for the value of elementX, elementY and isOutside on useMouseInElement when the element is not sticky.

If I scroll on a page the position of the mouse is not changing which is correct, but scrolling move elements in the page thus changing the position of the mouse in this element.
Since useMouseInElement is not updating elementX, elementY and isOutside, on scroll they end up been false.

To reproduce the problem you can use the doc :

place your cursor in the element then scoll, the elementX, elementY are not updating and if you scroll until the cursor is out of the element isOutside is still at false.

Reproduction

https://vueuse.org/core/useMouseInElement/

System Info

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M1
    Memory: 119.64 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Chrome: 111.0.5563.146
    Firefox: 111.0
    Safari: 16.3
  npmPackages:
    @vueuse/core: ^9.13.0 => 9.13.0 
    vue: ^3.2.47 => 3.2.47

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy