vue-drag-resize icon indicating copy to clipboard operation
vue-drag-resize copied to clipboard

请问什么条件下,才是激活的状态?

Open alicecoding opened this issue 6 years ago • 4 comments

场景如下: 1.设置:isActive="true",然后点击其他地方,这个时候,并没有把isActive给设置为false,为了业务需求,那么,当我再次回到这边的时候,拖动却无法响应,一定要点击一次,然后才可以拖动

alicecoding avatar Sep 07 '18 07:09 alicecoding

是的,我现在的项目也遇到了你的问题。请问你解决了吗

zhijinga avatar May 21 '19 02:05 zhijinga

我使用的是传值,不能直接定义为true,当点击其他地方设置false,点回来在设置为true,这样点回来就可以拖动。

zhijinga avatar May 21 '19 02:05 zhijinga

我也遇到了这个问题,大家是怎么解决的呀

wjhcc2018 avatar Jun 04 '19 10:06 wjhcc2018

我使用的是传值,不能直接定义为true,当点击其他地方设置false,点回来在设置为true,这样点回来就可以拖动。

按这个思路实现了一下

    mounted() {
        document.addEventListener("click", this.refreshActive)
    },
    beforeDestroy() {
        document.removeEventListener("click", this.refreshActive)
    },
    methods: {
        // reset active
        refreshActive(e) {
            const activeEls = this.$el.querySelectorAll(".vdr.active")
            if (!activeEls.length || Array.from(activeEls).some((el) => el.contains(e.target))) return
            this.isActive = false
            this.$nextTick(() => {
                this.isActive = true
            })
        },
  }

adndyxu avatar Dec 27 '23 09:12 adndyxu