uni-image-editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/components/edit-graffiti-config.vue +151 -0
- package/components/edit-text-config.vue +112 -0
- package/components/image-clipper/image-clipper.vue +1009 -0
- package/components/image-clipper/img/photo.svg +19 -0
- package/components/image-clipper/img/rotate.svg +15 -0
- package/components/image-clipper/index.scss +184 -0
- package/components/image-clipper/utils.js +280 -0
- package/components/input-text-modal.vue +431 -0
- package/image-editor.vue +971 -0
- package/js/const.js +242 -0
- package/js/editor.js +1179 -0
- package/js/utils.js +316 -0
- package/package.json +29 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 24.3.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
4
|
+
viewBox="0 0 30 30" style="enable-background:new 0 0 30 30;" xml:space="preserve">
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
.st0{fill:#606060;}
|
|
7
|
+
.st1{fill:none;stroke:#FFFFFF;stroke-width:2.4306;stroke-miterlimit:10;}
|
|
8
|
+
.st2{fill:#FFFFFF;}
|
|
9
|
+
</style>
|
|
10
|
+
<g>
|
|
11
|
+
<path class="st2" d="M11.6,11c0.4,0.4,0.6,0.9,0.6,1.5c0,0.6-0.2,1.1-0.6,1.4c-0.4,0.4-0.9,0.6-1.5,0.6c-0.6,0-1.1-0.2-1.5-0.6
|
|
12
|
+
c-0.4-0.4-0.6-0.9-0.6-1.4s0.2-1.1,0.6-1.5c0.4-0.4,0.9-0.6,1.5-0.6C10.8,10.4,11.2,10.6,11.6,11z M24.6,18.4V6.7H5.4v12l1.8-1.8
|
|
13
|
+
c0.3-0.3,0.6-0.4,1-0.4c0.4,0,0.7,0.1,1,0.4l1.8,1.8l5.8-7c0.3-0.3,0.6-0.5,1.1-0.5c0.4,0,0.8,0.2,1.1,0.5
|
|
14
|
+
C18.8,11.6,24.6,18.4,24.6,18.4z M25.6,5.7C25.9,6,26,6.3,26,6.7v16.1c0,0.4-0.1,0.7-0.4,1c-0.3,0.3-0.6,0.4-1,0.4H5.4
|
|
15
|
+
c-0.4,0-0.7-0.1-1-0.4c-0.3-0.3-0.4-0.6-0.4-1V6.7c0-0.4,0.1-0.7,0.4-1c0.3-0.3,0.6-0.4,1-0.4h19.3C25,5.3,25.3,5.4,25.6,5.7z"/>
|
|
16
|
+
<path class="st1" d="M24.3,21.5H5.7c-0.2,0-0.3-0.2-0.3-0.3V7c0-0.2,0.2-0.3,0.3-0.3h18.6c0.2,0,0.3,0.2,0.3,0.3v14.2
|
|
17
|
+
C24.6,21.3,24.5,21.5,24.3,21.5z"/>
|
|
18
|
+
</g>
|
|
19
|
+
</svg>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 24.3.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
4
|
+
width="30px" height="30px" viewBox="0 0 30 30" style="enable-background:new 0 0 30 30;" xml:space="preserve">
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
.st0{fill:none;stroke:#FFFFFF;stroke-width:2.4306;stroke-miterlimit:10;}
|
|
7
|
+
.st1{fill:#FFFFFF;}
|
|
8
|
+
</style>
|
|
9
|
+
<g>
|
|
10
|
+
<path class="st0" d="M17.1,24.2h-12c-0.2,0-0.3-0.2-0.3-0.3v-9.3c0-0.2,0.2-0.3,0.3-0.3h12c0.2,0,0.3,0.2,0.3,0.3v9.3
|
|
11
|
+
C17.5,24.1,17.3,24.2,17.1,24.2z"/>
|
|
12
|
+
<path class="st0" d="M16.6,5.4c4.8,0,8.7,3.9,8.7,8.7"/>
|
|
13
|
+
<polyline class="st0" points="19.3,10.1 14.9,5.6 19.3,1.2 "/>
|
|
14
|
+
</g>
|
|
15
|
+
</svg>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
$clipper-edge-border-width: 6rpx !default;
|
|
2
|
+
$clipper-confirm-color: #07c160 !default;
|
|
3
|
+
|
|
4
|
+
.flex-auto {
|
|
5
|
+
flex:auto
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.bg-transparent {
|
|
9
|
+
background-color: rgba(0, 0, 0, 0.9);
|
|
10
|
+
transition-duration: 0.35s;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.lime-clipper {
|
|
14
|
+
width: 100vw;
|
|
15
|
+
height: calc( 100vh - var(--window-top));
|
|
16
|
+
background-color: rgba(0, 0, 0, 0.9);
|
|
17
|
+
position: fixed;
|
|
18
|
+
top: var(--window-top);
|
|
19
|
+
left: 300vw;
|
|
20
|
+
z-index: 1;
|
|
21
|
+
&.open {
|
|
22
|
+
left: 0;
|
|
23
|
+
}
|
|
24
|
+
&-mask {
|
|
25
|
+
position: relative;
|
|
26
|
+
z-index: 2;
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
}
|
|
29
|
+
&__content {
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
position: absolute;
|
|
32
|
+
border: 1rpx solid rgba(255,255,255,.3);
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
box-shadow: rgba(0, 0, 0, 0.5) 0 0 0 80vh;
|
|
35
|
+
background: transparent;
|
|
36
|
+
// transition-duration 0.35s
|
|
37
|
+
// transition-property left,top
|
|
38
|
+
&::before,&::after {
|
|
39
|
+
content: '';
|
|
40
|
+
position: absolute;
|
|
41
|
+
border: 1rpx dashed rgba(255,255,255,.3);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&::before {
|
|
45
|
+
width: 100%;
|
|
46
|
+
top: 33.33%;
|
|
47
|
+
height: 33.33%;
|
|
48
|
+
border-left: none;
|
|
49
|
+
border-right: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&::after {
|
|
53
|
+
width: 33.33%;
|
|
54
|
+
left: 33.33%;
|
|
55
|
+
height: 100%;
|
|
56
|
+
border-top:none;
|
|
57
|
+
border-bottom: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&__edge {
|
|
63
|
+
position: absolute;
|
|
64
|
+
// left 6rpx
|
|
65
|
+
width: 34rpx;
|
|
66
|
+
height: 34rpx;
|
|
67
|
+
border: $clipper-edge-border-width solid #ffffff;
|
|
68
|
+
pointer-events: auto;
|
|
69
|
+
&::before {
|
|
70
|
+
content: '';
|
|
71
|
+
position: absolute;
|
|
72
|
+
width: 40rpx;
|
|
73
|
+
height: 40rpx;
|
|
74
|
+
background-color: transparent;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:nth-child(1) {
|
|
78
|
+
left: - $clipper-edge-border-width;
|
|
79
|
+
top: - $clipper-edge-border-width;
|
|
80
|
+
border-bottom-width: 0 !important;
|
|
81
|
+
border-right-width: 0 !important;
|
|
82
|
+
&:before {
|
|
83
|
+
top: -50%;
|
|
84
|
+
left: -50%;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&:nth-child(2) {
|
|
89
|
+
right: - $clipper-edge-border-width;
|
|
90
|
+
top: - $clipper-edge-border-width;
|
|
91
|
+
border-bottom-width: 0 !important;
|
|
92
|
+
border-left-width: 0 !important;
|
|
93
|
+
&:before {
|
|
94
|
+
top: -50%;
|
|
95
|
+
left: 50%;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&:nth-child(3) {
|
|
101
|
+
left: - $clipper-edge-border-width;
|
|
102
|
+
bottom: - $clipper-edge-border-width;
|
|
103
|
+
border-top-width: 0 !important;
|
|
104
|
+
border-right-width: 0 !important;
|
|
105
|
+
&:before {
|
|
106
|
+
bottom: -50%;
|
|
107
|
+
left: -50%;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&:nth-child(4) {
|
|
112
|
+
right: - $clipper-edge-border-width;
|
|
113
|
+
bottom: - $clipper-edge-border-width;
|
|
114
|
+
border-top-width: 0 !important;
|
|
115
|
+
border-left-width: 0 !important;
|
|
116
|
+
&:before {
|
|
117
|
+
bottom: -50%;
|
|
118
|
+
left: 50%;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&-image {
|
|
125
|
+
width: 100%;
|
|
126
|
+
max-width: inherit;
|
|
127
|
+
border-style: none;
|
|
128
|
+
position: absolute;
|
|
129
|
+
top: 0;
|
|
130
|
+
left: 0;
|
|
131
|
+
z-index: 1;
|
|
132
|
+
-webkit-backface-visibility: hidden;
|
|
133
|
+
backface-visibility: hidden;
|
|
134
|
+
transform-origin: center;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&-canvas {
|
|
138
|
+
position: fixed;
|
|
139
|
+
z-index: 10;
|
|
140
|
+
left: -200vw;
|
|
141
|
+
top: -200vw;
|
|
142
|
+
pointer-events: none;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&-tools {
|
|
146
|
+
position: absolute;
|
|
147
|
+
left: 0;
|
|
148
|
+
bottom: 10px;
|
|
149
|
+
width: 100%;
|
|
150
|
+
z-index: 99;
|
|
151
|
+
color: #fff;
|
|
152
|
+
&__btns {
|
|
153
|
+
font-weight: bold;
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: space-between;
|
|
157
|
+
width: 100%;
|
|
158
|
+
padding: 20rpx 40rpx;
|
|
159
|
+
box-sizing: border-box;
|
|
160
|
+
.cancel {
|
|
161
|
+
width: 112rpx;
|
|
162
|
+
height: 60rpx;
|
|
163
|
+
text-align: center;
|
|
164
|
+
line-height: 60rpx;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.confirm {
|
|
168
|
+
width: 112rpx;
|
|
169
|
+
height: 60rpx;
|
|
170
|
+
line-height: 60rpx;
|
|
171
|
+
background: var(--lime-clipper-confirm-color, $clipper-confirm-color);
|
|
172
|
+
border-radius: 6rpx;
|
|
173
|
+
text-align: center;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
image {
|
|
177
|
+
display: block;
|
|
178
|
+
width: 60rpx;
|
|
179
|
+
height: 60rpx;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断手指触摸位置
|
|
3
|
+
*/
|
|
4
|
+
export function determineDirection(
|
|
5
|
+
clipX,
|
|
6
|
+
clipY,
|
|
7
|
+
clipWidth,
|
|
8
|
+
clipHeight,
|
|
9
|
+
currentX,
|
|
10
|
+
currentY
|
|
11
|
+
) {
|
|
12
|
+
/*
|
|
13
|
+
* (右下>>1 右上>>2 左上>>3 左下>>4)
|
|
14
|
+
*/
|
|
15
|
+
let corner;
|
|
16
|
+
/**
|
|
17
|
+
* 思路:(利用直角坐标系)
|
|
18
|
+
* 1.找出裁剪框中心点
|
|
19
|
+
* 2.如点击坐标在上方点与左方点区域内,则点击为左上角
|
|
20
|
+
* 3.如点击坐标在下方点与右方点区域内,则点击为右下角
|
|
21
|
+
* 4.其他角同理
|
|
22
|
+
*/
|
|
23
|
+
const mainPoint = [clipX + clipWidth / 2, clipY + clipHeight / 2]; // 中心点
|
|
24
|
+
const currentPoint = [currentX, currentY]; // 触摸点
|
|
25
|
+
|
|
26
|
+
if (currentPoint[0] <= mainPoint[0] && currentPoint[1] <= mainPoint[1]) {
|
|
27
|
+
corner = 3; // 左上
|
|
28
|
+
} else if (
|
|
29
|
+
currentPoint[0] >= mainPoint[0] &&
|
|
30
|
+
currentPoint[1] <= mainPoint[1]
|
|
31
|
+
) {
|
|
32
|
+
corner = 2; // 右上
|
|
33
|
+
} else if (
|
|
34
|
+
currentPoint[0] <= mainPoint[0] &&
|
|
35
|
+
currentPoint[1] >= mainPoint[1]
|
|
36
|
+
) {
|
|
37
|
+
corner = 4; // 左下
|
|
38
|
+
} else if (
|
|
39
|
+
currentPoint[0] >= mainPoint[0] &&
|
|
40
|
+
currentPoint[1] >= mainPoint[1]
|
|
41
|
+
) {
|
|
42
|
+
corner = 1; // 右下
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return corner;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 图片边缘检测检测时,计算图片偏移量
|
|
50
|
+
*/
|
|
51
|
+
export function calcImageOffset(data, scale) {
|
|
52
|
+
let left = data.imageLeft;
|
|
53
|
+
let top = data.imageTop;
|
|
54
|
+
scale = scale || data.scale;
|
|
55
|
+
|
|
56
|
+
let imageWidth = data.imageWidth;
|
|
57
|
+
let imageHeight = data.imageHeight;
|
|
58
|
+
if ((data.angle / 90) % 2) {
|
|
59
|
+
imageWidth = data.imageHeight;
|
|
60
|
+
imageHeight = data.imageWidth;
|
|
61
|
+
}
|
|
62
|
+
const { clipX, clipWidth, clipY, clipHeight } = data;
|
|
63
|
+
|
|
64
|
+
// 当前图片宽度/高度
|
|
65
|
+
const currentImageSize = (size) => (size * scale) / 2;
|
|
66
|
+
const currentImageWidth = currentImageSize(imageWidth);
|
|
67
|
+
const currentImageHeight = currentImageSize(imageHeight);
|
|
68
|
+
|
|
69
|
+
left = clipX + currentImageWidth >= left ? left : clipX + currentImageWidth;
|
|
70
|
+
left =
|
|
71
|
+
clipX + clipWidth - currentImageWidth <= left
|
|
72
|
+
? left
|
|
73
|
+
: clipX + clipWidth - currentImageWidth;
|
|
74
|
+
top = clipY + currentImageHeight >= top ? top : clipY + currentImageHeight;
|
|
75
|
+
top =
|
|
76
|
+
clipY + clipHeight - currentImageHeight <= top
|
|
77
|
+
? top
|
|
78
|
+
: clipY + clipHeight - currentImageHeight;
|
|
79
|
+
return {
|
|
80
|
+
left,
|
|
81
|
+
top,
|
|
82
|
+
scale,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 图片边缘检测时,计算图片缩放比例
|
|
88
|
+
*/
|
|
89
|
+
export function calcImageScale(data, scale) {
|
|
90
|
+
scale = scale || data.scale;
|
|
91
|
+
let { imageWidth, imageHeight, clipWidth, clipHeight, angle } = data;
|
|
92
|
+
if ((angle / 90) % 2) {
|
|
93
|
+
[imageWidth, imageHeight] = [imageHeight, imageWidth];
|
|
94
|
+
}
|
|
95
|
+
if (
|
|
96
|
+
angle !== 0 &&
|
|
97
|
+
scale == Math.max(clipWidth / imageHeight, clipHeight / imageWidth)
|
|
98
|
+
) {
|
|
99
|
+
return Math.max(clipWidth / imageWidth, clipHeight / imageHeight);
|
|
100
|
+
}
|
|
101
|
+
if (imageWidth * scale < clipWidth) {
|
|
102
|
+
scale = clipWidth / imageWidth;
|
|
103
|
+
}
|
|
104
|
+
if (imageHeight * scale < clipHeight) {
|
|
105
|
+
scale = Math.max(scale, clipHeight / imageHeight);
|
|
106
|
+
}
|
|
107
|
+
return scale;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 计算图片尺寸
|
|
112
|
+
*/
|
|
113
|
+
export function calcImageSize(width, height, data) {
|
|
114
|
+
let imageWidth = width,
|
|
115
|
+
imageHeight = height;
|
|
116
|
+
let {
|
|
117
|
+
clipWidth,
|
|
118
|
+
clipHeight,
|
|
119
|
+
sysinfo,
|
|
120
|
+
width: originWidth,
|
|
121
|
+
height: originHeight,
|
|
122
|
+
} = data;
|
|
123
|
+
const cw = clipWidth || originWidth;
|
|
124
|
+
const ch = clipHeight || originHeight;
|
|
125
|
+
if (imageWidth && imageHeight) {
|
|
126
|
+
if (imageWidth / imageHeight > cw / ch) {
|
|
127
|
+
imageHeight = clipHeight || originHeight;
|
|
128
|
+
imageWidth = (width / height) * imageHeight;
|
|
129
|
+
} else {
|
|
130
|
+
imageWidth = cw;
|
|
131
|
+
imageHeight = (height / width) * imageWidth;
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
let sys = sysinfo || uni.getSystemInfoSync();
|
|
135
|
+
imageWidth = sys.windowWidth;
|
|
136
|
+
imageHeight = 0;
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
imageWidth,
|
|
140
|
+
imageHeight,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 勾股定理求斜边
|
|
146
|
+
*/
|
|
147
|
+
export function calcPythagoreanTheorem(width, height) {
|
|
148
|
+
return Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 拖动裁剪框时计算
|
|
153
|
+
*/
|
|
154
|
+
export function clipTouchMoveOfCalculate(data, event) {
|
|
155
|
+
const clientX = event.touches[0].clientX;
|
|
156
|
+
const clientY = event.touches[0].clientY;
|
|
157
|
+
|
|
158
|
+
let {
|
|
159
|
+
clipWidth,
|
|
160
|
+
clipHeight,
|
|
161
|
+
clipY: oldClipY,
|
|
162
|
+
clipX: oldClipX,
|
|
163
|
+
clipStart,
|
|
164
|
+
isLockRatio,
|
|
165
|
+
maxWidth,
|
|
166
|
+
minWidth,
|
|
167
|
+
maxHeight,
|
|
168
|
+
minHeight,
|
|
169
|
+
} = data;
|
|
170
|
+
maxWidth = uni.upx2px(maxWidth); // maxWidth / 2;
|
|
171
|
+
minWidth = uni.upx2px(minWidth); // minWidth / 2;
|
|
172
|
+
minHeight = uni.upx2px(minHeight); // minHeight / 2;
|
|
173
|
+
maxHeight = uni.upx2px(maxHeight); // maxHeight / 2;
|
|
174
|
+
|
|
175
|
+
let width = clipWidth,
|
|
176
|
+
height = clipHeight,
|
|
177
|
+
clipY = oldClipY,
|
|
178
|
+
clipX = oldClipX,
|
|
179
|
+
// 获取裁剪框实际宽度/高度
|
|
180
|
+
// 如果大于最大值则使用最大值
|
|
181
|
+
// 如果小于最小值则使用最小值
|
|
182
|
+
sizecorrect = () => {
|
|
183
|
+
width =
|
|
184
|
+
width <= maxWidth ? (width >= minWidth ? width : minWidth) : maxWidth;
|
|
185
|
+
height =
|
|
186
|
+
height <= maxHeight
|
|
187
|
+
? height >= minHeight
|
|
188
|
+
? height
|
|
189
|
+
: minHeight
|
|
190
|
+
: maxHeight;
|
|
191
|
+
},
|
|
192
|
+
sizeinspect = () => {
|
|
193
|
+
if (
|
|
194
|
+
(width > maxWidth ||
|
|
195
|
+
width < minWidth ||
|
|
196
|
+
height > maxHeight ||
|
|
197
|
+
height < minHeight) &&
|
|
198
|
+
isLockRatio
|
|
199
|
+
) {
|
|
200
|
+
sizecorrect();
|
|
201
|
+
return false;
|
|
202
|
+
} else {
|
|
203
|
+
sizecorrect();
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
//if (clipStart.corner) {
|
|
208
|
+
height =
|
|
209
|
+
clipStart.height +
|
|
210
|
+
(clipStart.corner > 1 && clipStart.corner < 4 ? 1 : -1) *
|
|
211
|
+
(clipStart.y - clientY);
|
|
212
|
+
//}
|
|
213
|
+
switch (clipStart.corner) {
|
|
214
|
+
case 1:
|
|
215
|
+
width = clipStart.width - clipStart.x + clientX;
|
|
216
|
+
if (isLockRatio) {
|
|
217
|
+
height = width / (clipWidth / clipHeight);
|
|
218
|
+
}
|
|
219
|
+
if (!sizeinspect()) return;
|
|
220
|
+
break;
|
|
221
|
+
case 2:
|
|
222
|
+
width = clipStart.width - clipStart.x + clientX;
|
|
223
|
+
if (isLockRatio) {
|
|
224
|
+
height = width / (clipWidth / clipHeight);
|
|
225
|
+
}
|
|
226
|
+
if (!sizeinspect()) {
|
|
227
|
+
return;
|
|
228
|
+
} else {
|
|
229
|
+
clipY = clipStart.clipY - (height - clipStart.height);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
break;
|
|
233
|
+
case 3:
|
|
234
|
+
width = clipStart.width + clipStart.x - clientX;
|
|
235
|
+
if (isLockRatio) {
|
|
236
|
+
height = width / (clipWidth / clipHeight);
|
|
237
|
+
}
|
|
238
|
+
if (!sizeinspect()) {
|
|
239
|
+
return;
|
|
240
|
+
} else {
|
|
241
|
+
clipY = clipStart.clipY - (height - clipStart.height);
|
|
242
|
+
clipX = clipStart.clipX - (width - clipStart.width);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
break;
|
|
246
|
+
case 4:
|
|
247
|
+
width = clipStart.width + clipStart.x - clientX;
|
|
248
|
+
if (isLockRatio) {
|
|
249
|
+
height = width / (clipWidth / clipHeight);
|
|
250
|
+
}
|
|
251
|
+
if (!sizeinspect()) {
|
|
252
|
+
return;
|
|
253
|
+
} else {
|
|
254
|
+
clipX = clipStart.clipX - (width - clipStart.width);
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
default:
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
width,
|
|
262
|
+
height,
|
|
263
|
+
clipX,
|
|
264
|
+
clipY,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 单指拖动图片计算偏移
|
|
270
|
+
*/
|
|
271
|
+
export function imageTouchMoveOfCalcOffset(
|
|
272
|
+
data,
|
|
273
|
+
clientXForLeft,
|
|
274
|
+
clientYForLeft
|
|
275
|
+
) {
|
|
276
|
+
return {
|
|
277
|
+
left: clientXForLeft - data.touchRelative[0].x,
|
|
278
|
+
top: clientYForLeft - data.touchRelative[0].y,
|
|
279
|
+
};
|
|
280
|
+
}
|