元素拖拽移动

@touchstart.stop="touchstartHandle_icon('dragBox',$event)"
                @touchmove.stop="touchmoveHandle_icon('dragBox',$event)"
                @touchend.stop="toucendveHandle_icon('dragBox',$event)"

<script>
    //开始拖动
            touchstartHandle(refName, e) {
              let element = e.changedTouches[0]
              this.startX = element.clientX
              this.startY = element.clientY
            },
            //正在拖动
            touchmoveHandle(refName, e) {
                var current = e.changedTouches[0];
                var x = current.clientX
                var y = current.clientY
                var w = this.startX - current.clientX
                var h = this.startY - current.clientY
                this.right = (-40 + 2*w) +'rpx';
                this.top = (this.nowTop - 2*h) +'rpx';
            },
            //结束拖动
            toucendveHandle(refName, e){
                var current = e.changedTouches[0];
                var x = current.clientX
                var y = current.clientY
                var h = this.startY - y
                this.right = '-40rpx'
                this.top = (this.nowTop - 2*h) +'rpx';
                this.nowTop = this.nowTop - 2*h
                this.isShowLog = 0
                if ((this.startX - x) == 0 && (this.startY - y) == 0) {
                    this.toLine()
                }
            },    

</script>

 

posted @ 2021-03-31 19:02  骅骝漫轻舞01  阅读(58)  评论(0编辑  收藏  举报