From 771d2a5f16819e243a4aa2785a7e5a79d7649e66 Mon Sep 17 00:00:00 2001 From: Joshua Date: Sun, 11 Aug 2019 20:49:17 +0800 Subject: [PATCH 1/2] Fixed deselecting when clicking the active content --- src/drr.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/drr.vue b/src/drr.vue index d4939f3..014300f 100644 --- a/src/drr.vue +++ b/src/drr.vue @@ -351,9 +351,21 @@ } }, - deselect() { - this.$emit('deselect') - this.active = false + deselect(e) { + const mouseX = e.pageX + const mouseY = e.pageY + if( + this.active && + ( + mouseX < this.$el.getBoundingClientRect().x && + mouseX < (this.$el.getBoundingClientRect().x + this.$el.getBoundingClientRect().width) && + mouseY > this.$el.getBoundingClientRect().y && + mouseY > (this.$el.getBoundingClientRect().y + this.$el.getBoundingClientRect().height) + ) + ) { + this.$emit('deselect') + this.active = false + } }, move(ev) { From d03048322a6381b90bfdb5e35ab106f414c610cf Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 12 Aug 2019 07:53:54 +0800 Subject: [PATCH 2/2] fix condition --- src/drr.vue | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/drr.vue b/src/drr.vue index 014300f..e991dde 100644 --- a/src/drr.vue +++ b/src/drr.vue @@ -354,15 +354,10 @@ deselect(e) { const mouseX = e.pageX const mouseY = e.pageY - if( - this.active && - ( - mouseX < this.$el.getBoundingClientRect().x && - mouseX < (this.$el.getBoundingClientRect().x + this.$el.getBoundingClientRect().width) && - mouseY > this.$el.getBoundingClientRect().y && - mouseY > (this.$el.getBoundingClientRect().y + this.$el.getBoundingClientRect().height) - ) - ) { + if(mouseX < this.$el.getBoundingClientRect().x || + mouseX > (this.$el.getBoundingClientRect().x + this.$el.getBoundingClientRect().width) || + mouseY < this.$el.getBoundingClientRect().y || + mouseY > (this.$el.getBoundingClientRect().y + this.$el.getBoundingClientRect().height)) { this.$emit('deselect') this.active = false }