Feat:mousedownEventPreventDefault选项支持控制节点的mousedown事件是否阻止默认事件

This commit is contained in:
街角小林 2024-10-12 11:12:03 +08:00
parent 6ffd26fd7f
commit 729533b3c1
3 changed files with 8 additions and 4 deletions

View File

@ -103,7 +103,7 @@ const mindMap = new MindMap({
# 微信交流群 # 微信交流群
微信添加`wanglinguanfang`拉你入群。根据过往的经验,大部分问题都可以通过文档解决,所以提问前请确保你已经阅读完了所有文档,文档里没有的可在群里提问,不必私聊作者。 微信添加`wanglinguanfang`拉你入群。根据过往的经验,大部分问题都可以通过查看issue列表或文档解决,所以提问前请确保你已经阅读完了所有文档,文档里没有的可在群里提问,不必私聊作者。
# star # star
@ -120,6 +120,8 @@ const mindMap = new MindMap({
开源不易,如果本项目有帮助到你的话,可以考虑请作者喝杯咖啡,你的支持是开发者持续维护的最大动力~ 开源不易,如果本项目有帮助到你的话,可以考虑请作者喝杯咖啡,你的支持是开发者持续维护的最大动力~
> 推荐使用支付宝,微信获取不到头像。转账请备注【思维导图】。 > 推荐使用支付宝,微信获取不到头像。转账请备注【思维导图】。
>
> 也可以通过购买付费插件来支持我们:[付费插件](https://wanglin2.github.io/mind-map-docs/plugins/about.html)。
<p> <p>
<img src="./web/src/assets/img/alipay.jpg" style="width: 300px" /> <img src="./web/src/assets/img/alipay.jpg" style="width: 300px" />

View File

@ -630,12 +630,15 @@ class MindMapNode {
this.active(e) this.active(e)
}) })
this.group.on('mousedown', e => { this.group.on('mousedown', e => {
e.preventDefault()
const { const {
readonly, readonly,
enableCtrlKeyNodeSelection, enableCtrlKeyNodeSelection,
useLeftKeySelectionRightKeyDrag useLeftKeySelectionRightKeyDrag,
mousedownEventPreventDefault
} = this.mindMap.opt } = this.mindMap.opt
if (mousedownEventPreventDefault) {
e.preventDefault()
}
// 只读模式不需要阻止冒泡 // 只读模式不需要阻止冒泡
if (!readonly) { if (!readonly) {
if (this.isRoot) { if (this.isRoot) {

View File

@ -93,7 +93,6 @@ class Drag extends Base {
) { ) {
return return
} }
e.preventDefault()
this.isMousedown = true this.isMousedown = true
// 记录鼠标按下时的节点 // 记录鼠标按下时的节点
this.mousedownNode = node this.mousedownNode = node