-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat: support both mouse selection with the left mouse button and panning with the middle mouse button in the graph #3965
feat: support both mouse selection with the left mouse button and panning with the middle mouse button in the graph #3965
Conversation
💖 Thanks for opening this pull request! 💖 Please follow the contributing guidelines. And we use semantic commit messages to streamline the release process. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #3965 +/- ##
=======================================
Coverage 10.35% 10.35%
=======================================
Files 180 180
Lines 10529 10529
Branches 2565 2565
=======================================
Hits 1090 1090
Misses 9350 9350
Partials 89 89
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…ion-panning-mouse-event-conflict
… change eventTypes
@@ -320,6 +320,14 @@ export class Selection | |||
} | |||
|
|||
protected onBlankMouseDown({ e }: EventArgs['blank:mousedown']) { | |||
const eventTypes = this.options.eventTypes | |||
if ( | |||
!(eventTypes && eventTypes.includes('leftMouseDown') && e.button === 0) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不好意思,这么晚才来 review 你的代码。十分抱歉。这里我感觉这样更合理:
protected allowBlankMouseDown() {
const eventTypes = this.options.eventTypes
return eventTypes.includes('leftMouseDown') && e.button === 0 || eventTypes.includes('mouseWheelDown') && e.button === 1
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
谢谢, 我周末修一下
packages/x6/src/graph/panning.ts
Outdated
@@ -102,7 +102,10 @@ export class PanningManager extends Base { | |||
|
|||
protected onMouseDown({ e }: { e: Dom.MouseDownEvent }) { | |||
const eventTypes = this.widgetOptions.eventTypes | |||
if (!(eventTypes && eventTypes.includes('leftMouseDown'))) { | |||
if ( | |||
!(eventTypes && eventTypes.includes('leftMouseDown') && e.button === 0) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
请问 这个功能能支持动态修改交互的鼠标按键吗? 比如我想要一开始默认是中键移动画布,然后想动态修改为左键和中键一起能移动等等 @aMoonkin |
目前不支持, 理论来说好支持, Selection 暴露一个接口就可以了. |
Congrats on merging your first pull request! 🎉🎉🎉 |
Description
support both mouse selection with the left mouse button and panning with the middle mouse button in the graph.
在画布中同时支持左键框选和中键 panning
Motivation and Context
Problem
Expected to support both mouse selection with the left mouse button and panning with the middle mouse button in the graph. But
期待在在画布中同时支持左键框选和中键 panning
Changes
mouseWheelDown
, 用于处理仅在鼠标滚轮点击时的移动行为Concern
multipleSelectionModifiers: [],
in the selection configuration actually expects not to use any of the multiple selection buttons, but still makes the default configuration ['ctrl', 'meta'] take effect, so I used the following code to handle the behavior ofeventType
in my code. 'meta'] to take effect, so I handled the behavior ofeventType
in my code with the following code.leftMouseDown
of theeventTypes
option in panning does not actually distinguish between the mouse down behavior of the left mouse button and the mouse wheel, whereas theleftMouseDown
of the selectioneventTypes
option in panning only represents the mouse down behavior of the left mouse button. behavior of the left mouse button. Consider whether to accept this difference, and whether it is possible to support left mouse button and scroll wheel clicks independently on a larger scale.multipleSelectionModifiers: [],
, 实际是期待不使用任意一个多选按键, 但依然会使得默认配置 ['ctrl', 'meta'] 生效, 因此我在代码中用以下代码处理了eventType
的行为.eventTypes
选项的leftMouseDown
实际没有区分鼠标左键和滚轮的 mouse down 行为, 而在本次新增的 selectioneventTypes
选项中的leftMouseDown
却仅代表鼠标左键的 mouse down 行为. 考虑是否接受这种差异性, 以及能否在更大规模的范围中独立支持鼠标左键和滚轮的点击行为.Types of changes
Self Check before Merge