Demo:修复鼠标移出小地图再松开后事件没有结束的问题

This commit is contained in:
街角小林 2024-07-02 16:30:19 +08:00
parent 5c1e5f072c
commit 00f86fe167
2 changed files with 10 additions and 6 deletions

View File

@ -53,13 +53,16 @@ class MiniMap {
let miniMapBoxScale = actWidth / rect.width
let miniMapBoxLeft = (boxWidth - actWidth) / 2
let miniMapBoxTop = (boxHeight - actHeight) / 2
// 视口框大小及位置
let _rectX = rect.x - (rect.width * scaleX - rect.width) / 2
let _rectX2 = rect.x2 + (rect.width * scaleX - rect.width) / 2
let _rectY = rect.y - (rect.height * scaleY - rect.height) / 2
let _rectY2 = rect.y2 + (rect.height * scaleY - rect.height) / 2
// 当前思维导图图形实际的宽高,即在缩放后的宽高
let _rectWidth = rect.width * scaleX
let _rectHeight = rect.height * scaleY
// 视口框大小及位置
let _rectWidthOffsetHalf = (_rectWidth - rect.width) / 2
let _rectHeightOffsetHalf = (_rectHeight - rect.height) / 2
let _rectX = rect.x - _rectWidthOffsetHalf
let _rectX2 = rect.x2 + _rectWidthOffsetHalf
let _rectY = rect.y - _rectHeightOffsetHalf
let _rectY2 = rect.y2 + _rectHeightOffsetHalf
let viewBoxStyle = {
left: 0,
top: 0,

View File

@ -7,7 +7,6 @@
:style="{ width: width + 'px' }"
@mousedown="onMousedown"
@mousemove="onMousemove"
@mouseup="onMouseup"
>
<div
class="svgBox"
@ -65,6 +64,7 @@ export default {
this.$bus.$on('data_change', this.data_change)
this.$bus.$on('view_data_change', this.data_change)
this.$bus.$on('node_tree_render_end', this.data_change)
window.addEventListener('mouseup', this.onMouseup)
},
destroyed() {
window.removeEventListener('resize', this.setSize)
@ -72,6 +72,7 @@ export default {
this.$bus.$off('data_change', this.data_change)
this.$bus.$off('view_data_change', this.data_change)
this.$bus.$off('node_tree_render_end', this.data_change)
window.removeEventListener('mouseup', this.onMouseup)
},
methods: {
//