Skip to content

[useMouse()] mouse.y is off by 0.5 and shows as -0.5 when at the very top of the tracked element #232

Description

@c0dezer019

Describe the bug
Regardless of position, position increments as 1 and starts at 0.5, so 1.5, 2.5, 3.5 etc. Will track to -0.5 before pos value is set to none (when mouse is slightly just above the element).

To Reproduce
Steps to reproduce the behavior:

  1. Setup a div as specified in the instructions. Add <p>x: {mouse.x} y: {mouse.y}</p> to display pos within element.
  2. Start from the top
  3. Move mouse down the tracked div.
  4. Reverse steps.

Expected behavior
y is not offset by 0.5 and that the numbers either freeze (preferably freeze) or not displayed when pos is exactly 0.

Screenshots
error

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Brave
  • Version: 1.42.97

Additional context
Done with Next.JS and on a styled-component element. Not sure that this would be a cause though.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions