-
zhangwei
2025-03-06 8c047f7da19d7e59136a322e1a851d4b6b0eab97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// 本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID:16  3,营业执照号:9  15   1013  13  3200   61    9 3K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。
// #ifndef APP-PLUS || MP-WEIXIN || H5
export default {
    data() {
        return {
            startX: 0,
            startY: 0,
            lastLeft: 0,
            lastTop: 0,
            transform: ''
        }
    },
    watch: {
        resetNum(val) {
            if (val > 0) {
                this.startX = 0;
                this.startY = 0;
                this.lastLeft = 0;
                this.lastTop = 0;
                this.transform = 'translate3d(0,0,0)'
            }
        }
    },
    methods: {
        touchstart(e) {
            if (!this.isDrag) return;
            const touch = e.touches || e.changedTouches
            this.startX = touch[0].clientX
            this.startY = touch[0].clientY
        },
        touchmove(e) {
            if (!this.isDrag) return;
            const touch = e.touches || e.changedTouches
            let pageX = touch[0].clientX,
                pageY = touch[0].clientY;
 
            var left = pageX - this.startX + this.lastLeft;
            left = left < -this.eLeft ? -this.eLeft : left;
            left = left > this.maxWidth ? this.maxWidth : left;
            this.startX = pageX
 
            var top = pageY - this.startY + this.lastTop;
            top = top < -this.eTop ? -this.eTop : top;
            top = top > this.maxHeight ? this.maxHeight : top;
            this.startY = pageY
 
 
            this.lastLeft = left
            this.lastTop = top
            this.transform = `translate3d(${left}px,${top}px,0)`
        }
    }
}
 
// #endif
 
// #ifdef APP-PLUS|| MP-WEIXIN || H5
export default {}
// #endif