Skip to content

Commit bc3bf46

Browse files
committed
add new crop vue
1 parent c23967a commit bc3bf46

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

dist/crop.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export default {
253253
this.width = w;
254254
this.height = h;
255255
} else {
256-
if (r >= 1) {
256+
if (r >= this.cropCSS.width/this.cropCSS.height) {
257257
this.height = this.cropCSS.height;
258258
this.width = this.height * r;
259259
} else {

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/vue-core-image-upload.vue

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
<div class="g-core-image-corp-container" v-bind:id="'vciu-modal-' + formID" v-show="hasImage">
88
<crop ref="cropBox" :is-resize="resize && !crop" :ratio="cropRatio"></crop>
99
<div class="info-aside">
10+
<p class="btn-groups rotate-groups" v-if="crop">
11+
<button type="button" v-on:click="doRotate" class="btn btn-rotate">↺</button>
12+
<button type="button" v-on:click="doReverseRotate" class="btn btn-reverserotate">↻</button>
13+
</p>
1014
<p class="btn-groups" v-if="crop">
1115
<button type="button" v-on:click="doCrop" class="btn btn-upload">{{cropBtn.ok}}</button>
1216
<button type="button" v-on:click="cancel" class="btn btn-cancel">{{cropBtn.cancel}}</button>
@@ -133,7 +137,9 @@
133137
const cropBox = this.$refs.cropBox;
134138
pic.onload= function() {
135139
self.image.minProgress = self.minWidth / pic.naturalWidth;
136-
self.imgChangeRatio = cropBox.setImage(src, pic.naturalWidth, pic.naturalHeight);
140+
canvasHelper.init(src, (src) => {
141+
self.imgChangeRatio = cropBox.setImage(src, pic.naturalWidth, pic.naturalHeight);
142+
});
137143
}
138144
},
139145
@@ -142,6 +148,26 @@
142148
cropBox.resizeImage(progress);
143149
},
144150
151+
doRotate(e) {
152+
let self = this;
153+
const cropBox = this.$refs.cropBox;
154+
const targetImage = cropBox.getCropImage();
155+
this.data.comprose = 100 - this.compress;
156+
return canvasHelper.rotate(targetImage, 1, (src) => {
157+
self.__initImage(src)
158+
})
159+
},
160+
161+
doReverseRotate(e) {
162+
let self = this;
163+
const cropBox = this.$refs.cropBox;
164+
const targetImage = cropBox.getCropImage();
165+
this.data.comprose = 100 - this.compress;
166+
return canvasHelper.rotate(targetImage, -1, (src) => {
167+
self.__initImage(src)
168+
})
169+
},
170+
145171
doCrop(e) {
146172
this.__setData('crop');
147173
const cropBox = this.$refs.cropBox;
@@ -159,7 +185,7 @@
159185
},
160186
161187
doResize(e) {
162-
this.__setData('reszie');
188+
this.__setData('resize');
163189
const cropBox = this.$refs.cropBox;
164190
const upload = this.__setUpload(e.target);
165191
if (this.resize === 'local') {

index.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)