Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path() should return an empty array when start and end are the same #159

Open
regseb opened this issue Mar 2, 2025 · 0 comments
Open

path() should return an empty array when start and end are the same #159

regseb opened this issue Mar 2, 2025 · 0 comments

Comments

@regseb
Copy link

regseb commented Mar 2, 2025

The path() method should return an empty array when the start and end points are the same. Currently, the method returns NaN values.

I have a function in my code that humanizes all cursor movements with ghost-cursor. Sometimes I want to “move” the cursor to the same place. If, for example, I click on a button and then click again on the same button.

import { path } from "ghost-cursor";

console.log(path(
    { x: 42, y: 42 },
    { x: 42, y: 42 },
));
  • Expected:

    []
    
  • Actual:

    [
      { x: 42, y: 42 },   { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN }, { x: NaN, y: NaN },
      ... 1 more item
    ]
    
@regseb regseb changed the title path should return an empty array when start and end are the same path() should return an empty array when start and end are the same Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant