Skip to content

Commit 83e4e93

Browse files
committed
add new demo
1 parent e225b4b commit 83e4e93

File tree

6 files changed

+12
-18
lines changed

6 files changed

+12
-18
lines changed

demo/demo.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/upload.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h3 class="content-subhead">
3939
<div class="user">
4040
<img class="avatar" v-bind:src="src"/>
4141
</div>
42-
<vue-core-image-upload v-bind:class="['pure-button','pure-button-primary','js-btn-crop']" v-bind:crop="false" v-on:imageuploaded="imageuploaded" url="http://101.198.151.190/api/upload.php" extensions="png,gif,jpeg,jpg" input-accept="image/*"></vue-core-image-upload>
42+
<vue-core-image-upload v-bind:class="['pure-button','pure-button-primary','js-btn-crop']" v-bind:crop="false" v-on:imageuploaded="imageuploaded" v-bind:max-file-size="5242880" url="http://101.198.151.190/api/upload.php" extensions="png,gif,jpeg,jpg" v-on:errorhandle="errorhandle" input-accept="image/*"></vue-core-image-upload>
4343
<p>Click button to upload your image</p>
4444
<pre class="highlight javascript"><code>
4545
import VueCoreImageUpload from './vue.core.image.upload.vue';

index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-core-image-upload",
3-
"version": "2.0.6",
3+
"version": "2.0.9",
44
"description": "a vue plgin for image upload and crop",
55
"main": "index.js",
66
"dependencies": {

src/lib/resize.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ export default class Resize {
4343
if (!this.el) {
4444
return;
4545
}
46-
const $dotBox = document.querySelector('.g-crop-image-principal');
47-
const dotBoxW = window.getComputedStyle($dotBox).width;
48-
const dotBoxH = window.getComputedStyle($dotBox).height;
46+
const $dotBox = this.container;
47+
const dotBoxW = parseInt(window.getComputedStyle($dotBox).width);
48+
const dotBoxH = parseInt(window.getComputedStyle($dotBox).height);
4949
const $topH = document.querySelector('.info-aside');
5050
const $halfX = W - dotBoxW;
5151
const $halfY = H - dotBoxH - window.getComputedStyle($topH).height;
5252
const resetX = isMobile ? e.changedTouches[0]['clientX'] : e.clientX;
5353
const resetY = isMobile ? e.changedTouches[0]['clientY'] : e.clientY;
54-
5554
if (this.splitX > this.splitY) {
5655
if (parseInt(resetX) <= ($halfX / 2) + dotBoxW) {
5756
if (parseInt(this.el.offsetWidth) >= dotBoxW) {
@@ -112,11 +111,6 @@ export default class Resize {
112111
this.el.style.width = this.el.style.height = dotBoxW;
113112
}
114113
}
115-
// if(isMobile) {
116-
// document.addEventListener('touchend',this.stopDrag.bind(this),false);
117-
// } else {
118-
// document.addEventListener('mouseup',this.stopDrag.bind(this),false);
119-
// }
120114
}
121115

122116
stopDrag() {

src/vue.core.image.upload.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@
326326
if(extensionsArr.length>1) {
327327
var reg = new RegExp('^[' + extensionsArr.join('|') + ']+$','i');
328328
if (!reg.test(fileExt)) {
329-
return this.__dispatch('errorHandle','TYPE ERROR');
329+
return this.__dispatch('errorhandle','TYPE ERROR');
330330
}
331331
}
332332
@@ -339,8 +339,8 @@
339339
} else {
340340
formatSize = options.maxFileSize.toFixed(2) + 'Byte';
341341
}
342-
this.errorHandle('FILE IS TOO LARGER MAX FILE IS ' + formatSize);
343-
return;
342+
console.warn('FILE IS TOO LARGER MAX FILE IS ' + formatSize);
343+
return this.__dispatch('errorhandle','FILE IS TOO LARGER MAX FILE IS ' + formatSize);
344344
}
345345
346346
this.files = e.target.files;

0 commit comments

Comments
 (0)