From b1dd9038ef8df7f4848de3d71a0feb41f0ace373 Mon Sep 17 00:00:00 2001 From: HLN177 Date: Wed, 17 Jan 2024 18:12:29 +0000 Subject: [PATCH] fix: Limit calculation bug when dragging or resizing with both left and right mouse buttons clicked simultaneously --- src/components/vue-draggable-resizable.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/vue-draggable-resizable.vue b/src/components/vue-draggable-resizable.vue index 465a3d2..22bc1a0 100644 --- a/src/components/vue-draggable-resizable.vue +++ b/src/components/vue-draggable-resizable.vue @@ -253,6 +253,7 @@ export default { handle: null, enabled: this.active, resizing: false, + clicking: false, dragging: false, dragEnable: false, resizeEnable: false, @@ -395,6 +396,8 @@ export default { this.mouseClickPosition.top = this.top this.mouseClickPosition.bottom = this.bottom + this.clicking = true + if (this.parent) { this.bounds = this.calcDragLimits() } @@ -418,7 +421,7 @@ export default { deselect (e) { const target = e.target || e.srcElement const regex = new RegExp(this.className + '-([trmbl]{2})', '') - + if (!this.$el.contains(target) && !regex.test(target.className)) { if (this.enabled && !this.preventDeactivation) { this.enabled = false @@ -430,7 +433,7 @@ export default { removeEvent(document.documentElement, eventsFor.move, this.handleResize) } - this.resetBoundsAndMouseState() + !this.clicking && this.resetBoundsAndMouseState() }, handleTouchDown (handle, e) { eventsFor = events.touch @@ -467,6 +470,8 @@ export default { this.bounds = this.calcResizeLimits() + this.clicking = true + addEvent(document.documentElement, eventsFor.move, this.handleResize) addEvent(document.documentElement, eventsFor.stop, this.handleUp) }, @@ -773,6 +778,10 @@ export default { this.$emit('dragStop', this.left, this.top) } + if (this.clicking) { + this.clicking = false + } + removeEvent(document.documentElement, eventsFor.move, this.handleResize) } },