vue拖动div盒子-模态框

287 阅读1分钟

··· // @mousedown="gotouchstart" @mouseup="gotouchmove" gotouchstart(e) { var disx = e.x - this.refs.dialogsearch.getBoundingClientRect().leftvardisy=e.ythis.refs.dialog_search.getBoundingClientRect().left var disy = e.y - this.refs.dialog_search.getBoundingClientRect().top console.log(this.refs.dialog_search.getBoundingClientRect().left, disy, e) this.loop = setTimeout(() => { this.refs.dialog_search.style.left = e.x - this.refs.searchinput.getBoundingClientRect().left.toFixed(0)250+pxthis.refs.search_input.getBoundingClientRect().left.toFixed(0) - 250 + 'px' this.refs.dialog_search.style.top = e.y - this.$refs.search_input.getBoundingClientRect().top.toFixed(0) - 20 + 'px' }, 0) window.onmousemove = this.gotouchstart }, // 手释放,如果在500毫秒内就释放,则取消长按事件,此时可以执行onclick应该执行的事件 // gotouchend() {

// },
// 如果手指有移动,则取消所有事件,此时说明用户只是要移动而不是长按
gotouchmove(e) {
  window.onmousemove = null
  document.onmousemove = null
}

···