-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Bug]: Inconsistency of events when more buttons are used #10027
Comments
嗯。。。 鼠标右键的点击也会触发你设置的mouse:down, mouse:move 和 mouse:up。 你可以通过opt.e.button判断。它的值可以是以下之一: // translate |
This is something to fix, but is not trivial, all the interactions are built around the left mouse button and that is very restrictive for mixed events |
There are also other issues on the same topic |
@zhe-he 试过,无效 |
@sushuier const down = (e: TPointerEventInfo<MouseEvent>) => {
if (e.e.button != 0) return;
let lastPosX = e.e.clientX;
let lastPosY = e.e.clientY;
const move = (ev: MouseEvent) => {
const vpt = canvas.viewportTransform.slice(0) as TMat2D;
vpt[4] += ev.clientX - lastPosX;
vpt[5] += ev.clientY - lastPosY;
canvas.setViewportTransform(vpt);
canvas.requestRenderAll();
lastPosX = ev.clientX;
lastPosY = ev.clientY;
};
document.addEventListener("mousemove", move, { passive: true });
document.addEventListener(
"mouseup",
(_) => {
document.removeEventListener("mousemove", move);
},
{ once: true }
);
};
canvas.on("mouse:down", down); |
已测试,无效;这个bug有操作步骤的;你确定有理解我提的bug吗,操作步骤: |
Shouldn't we add fabric.js/src/canvas/Canvas.ts Lines 992 to 1000 in 6d120a0
fabric.js/src/canvas/Canvas.ts Lines 781 to 790 in 6d120a0
|
@sushuier 你列举的这些,是我上面说到的临时变量的一部分。 When the mouse is pressed down, a temporary variable will be set internally. |
This issue needs to be fixed in a way that if you press more buttons the events fire anyway. |
I'm sorry, translating from Chinese to English and then back to Chinese can lead to ambiguity. Therefore, when I encounter Chinese speakers, I use Chinese to avoid misunderstandings. This is my issue. |
CheckList
Version
5.3.0
In What environments are you experiencing the problem?
Chrome
Node Version (if applicable)
14.20.0
Link To Reproduction
https://codesandbox.io/p/devbox/fabric-vanillajs-sandbox-forked-e5r48u?file=%2Fsrc%2Findex.ts
Steps To Reproduce
中文:在画布上绘制任意一个图形,点击鼠标左键选中后,点击鼠标右键,松开鼠标左键和右键;图形会跟随鼠标移动;
chatgpt translate:Draw any shape on the canvas. After selecting it by clicking the left mouse button, click the right mouse button and release both the left and right mouse buttons; the shape will follow the mouse movement.
Expected Behavior
中文:点击鼠标右键,不要影响到左键的正常拖拽操作
chatgpt translate: Clicking the right mouse button should not affect the normal drag operation of the left mouse button.
Actual Behavior
code:
test video:
2024-07-28.00-25-23.mp4
Error Message & Stack Trace
No response
The text was updated successfully, but these errors were encountered: