Skip to content

Commit a78515a

Browse files
authored
Merge pull request #110 from Vanthink-UED/feature_support_exif
Feature support exif
2 parents bc3bf46 + 21adbf1 commit a78515a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+339
-1415
lines changed

.eslintrc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"no-console": 0,
2828
"comma-dangle": 0,
2929
"no-extra-semi": 0,
30+
"space-before-function-paren": 0,
31+
"no-underscore-dangle": 0,
3032
"semi": ["error", "always"]
3133
}
3234
}

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
site
2+
.eslintrc.json
3+
shots
4+
.babelrc
5+
webpack.config.js

UPDATE.log

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### TODO List
2+
3+
Fixed 旋转的 bug
4+
5+
旋转的定位
6+
7+
读取头部 exif
8+
9+
获取正确的定位

dist/crop.vue

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</div>
1919
</div>
2020
<resize-bar v-if="resize" ref="resizeBar" @resize="resizeImage"></resize-bar>
21+
<rotate-bar v-if="isRotate" @rotate="rotateImage"></rotate-bar>
2122
</div>
2223
</div>
2324
</template>
@@ -130,7 +131,9 @@ import drag from './lib/drag';
130131
import resize from './lib/resize';
131132
import GIF_LOADING_SRC from './lib/loading-gif';
132133
import helper from './lib/helper';
134+
import canvasHelper from './lib/canvas-helper';
133135
import ResizeBar from './resize-bar.vue';
136+
import RotateBar from './rotate-bar.vue';
134137
// set cropbox size in image
135138
const CROPBOX_PERCENT = 75;
136139
const isMobile = helper.isMobile;
@@ -139,6 +142,7 @@ const areaHeight = window.innerHeight - 110;
139142
export default {
140143
components: {
141144
ResizeBar,
145+
RotateBar,
142146
},
143147
props: {
144148
ratio: {
@@ -156,6 +160,10 @@ export default {
156160
isResize: {
157161
type: [Boolean],
158162
default: false,
163+
},
164+
isRotate: {
165+
type: [Boolean],
166+
default: true,
159167
}
160168
},
161169
@@ -177,6 +185,9 @@ export default {
177185
methods: {
178186
setImage(src, w, h) {
179187
this.src = src;
188+
if (!this.originSrc) {
189+
this.setOriginalSrc(this.src);
190+
}
180191
if (this.ratio.indexOf(':') > 0) {
181192
this.ratioW = this.ratio.split(':')[0];
182193
this.ratioH = this.ratio.split(':')[1];
@@ -197,6 +208,11 @@ export default {
197208
}
198209
return this.imgChangeRatio;
199210
},
211+
212+
setOriginalSrc(src) {
213+
this.originSrc = src;
214+
},
215+
200216
resizeImage(progress) {
201217
let w,
202218
h;
@@ -217,14 +233,20 @@ export default {
217233
this.imgChangeRatio = this.width / this.natrualWidth;
218234
},
219235
236+
rotateImage(degress) {
237+
const data = canvasHelper.rotate2(this.originSrc, degress, (data, w, h) => {
238+
this.setImage(data, w, h);
239+
});
240+
//this.src = src;
241+
},
242+
220243
setLayout(w, h) {
221244
let H = areaHeight,
222245
W = areaWidth,
223246
width = w,
224247
height = h,
225248
marginLeft = 0,
226249
marginTop = 0;
227-
228250
// caculate the image ratio
229251
let R = width / height;
230252
let Rs = W / H;
@@ -349,13 +371,13 @@ export default {
349371
};
350372
this.el = $el;
351373
this.container = $container;
374+
const maxCoor = this._getMaxCropAreaWidth();
352375
const move = function (ev) {
353376
const newCropStyle = resize(ev, self.el, $container, coor, self.ratioVal);
354-
if (newCropStyle) {
377+
if (newCropStyle && (newCropStyle.width <= maxCoor.maxWidth || newCropStyle.height <= maxCoor.maxHeight)) {
355378
self.cropCSS.width = newCropStyle.width;
356379
self.cropCSS.height = newCropStyle.height;
357380
}
358-
359381
};
360382
const end = function (ev) {
361383
this.el = null;
@@ -374,6 +396,20 @@ export default {
374396
document.addEventListener('mouseup', end, false);
375397
},
376398
399+
_getMaxCropAreaWidth() {
400+
const $cropBox = this.__find('.crop-box');
401+
if (this.width > this.height) {
402+
return {
403+
maxWidth: this.height * this.ratioW / this.ratioH,
404+
maxHeight: this.height,
405+
}
406+
}
407+
return {
408+
maxWidth: this.width,
409+
maxHeight: this.width * this.ratioH / this.ratioW,
410+
};
411+
},
412+
377413
drag(e) {
378414
e.preventDefault();
379415
const $el = this.__find('.image-wrap');

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import VueCoreImageUpload from './vue-core-image-upload.vue';
1+
import VueCoreImageUpload from 'vue-core-image-upload';
22
export default VueCoreImageUpload;

dist/lib/canvas-helper.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lib/drag.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)