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

The issue of mousemove being too sensitive: when a user clicks to select a shape, it might trigger the mousemove event (the shape is moved by 1px). #10387

Open
asturur opened this issue Jan 6, 2025 Discussed in #10377 · 0 comments

Comments

@asturur
Copy link
Member

asturur commented Jan 6, 2025

Discussed in #10377

Originally posted by zhe-he January 2, 2025
When the user clicks, can dragging be made lazy, for example, like this(It only enables the shape-moving functionality when the initial movement exceeds a specified number of pixels after pressing down)?

const __lastOnMouseDown = Canvas.prototype.__onMouseDown;
const __lastOnMouseMove = Canvas.prototype.__onMouseMove;
const __lastOnMouseUp = Canvas.prototype.__onMouseUp;

let moveCheckFlag = false;
const moveCheckDis = 5; 

Canvas.prototype.__onMouseMove = function (e) {
    if (moveCheckFlag && this._currentTransform?.target?.selectable) {
        const disX = e.pageX - e.pageY;
        const disY = e.pageY - e.pageY;
        if (Math.abs(disX) < moveCheckDis && Math.abs(disY) < moveCheckDis) return;
       moveCheckFlag = false;
    }
    __lastOnMouseMove.call(this, e);
}

Canvas.prototype.__onMouseDown = function (e) {
   moveCheckFlag = true;
   __lastOnMouseDown.call(this, e);
}
Canvas.prototype.__onMouseUp = function (e) {
   moveCheckFlag = false;
   __lastOnMouseUp.call(this, e)
}
```</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant