Skip to content

Commit 4e553bd

Browse files
committed
v1.3.7
1 parent eed7dd7 commit 4e553bd

File tree

6 files changed

+41
-33
lines changed

6 files changed

+41
-33
lines changed

dist/vue-croppa.js

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* vue-croppa v1.3.6
2+
* vue-croppa v1.3.7
33
* https://github.com/zhanziyang/vue-croppa
44
*
55
* Copyright (c) 2018 zhanziyang
@@ -434,15 +434,15 @@ var events = {
434434
FILE_CHOOSE_EVENT: 'file-choose',
435435
FILE_SIZE_EXCEED_EVENT: 'file-size-exceed',
436436
FILE_TYPE_MISMATCH_EVENT: 'file-type-mismatch',
437-
NEW_IMAGE: 'new-image',
438-
NEW_IMAGE_DRAWN: 'new-image-drawn',
437+
NEW_IMAGE_EVENT: 'new-image',
438+
NEW_IMAGE_DRAWN_EVENT: 'new-image-drawn',
439439
IMAGE_REMOVE_EVENT: 'image-remove',
440440
MOVE_EVENT: 'move',
441441
ZOOM_EVENT: 'zoom',
442-
DRAW: 'draw',
442+
DRAW_EVENT: 'draw',
443443
INITIAL_IMAGE_LOADED_EVENT: 'initial-image-loaded',
444-
LOADING_START: 'loading-start',
445-
LOADING_END: 'loading-end'
444+
LOADING_START_EVENT: 'loading-start',
445+
LOADING_END_EVENT: 'loading-end'
446446
};
447447

448448
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
@@ -707,7 +707,7 @@ var component = { render: function render() {
707707
this.scaleRatio = val / this.naturalWidth;
708708
if (this.hasImage()) {
709709
if (Math.abs(val - oldVal) > val * (1 / 100000)) {
710-
this.$emit(events.ZOOM_EVENT);
710+
this.emitEvent(events.ZOOM_EVENT);
711711
this._draw();
712712
}
713713
}
@@ -732,9 +732,9 @@ var component = { render: function render() {
732732
loading: function loading(val) {
733733
if (this.passive) return;
734734
if (val) {
735-
this.$emit(events.LOADING_START);
735+
this.emitEvent(events.LOADING_START_EVENT);
736736
} else {
737-
this.$emit(events.LOADING_END);
737+
this.emitEvent(events.LOADING_END_EVENT);
738738
}
739739
},
740740
autoSizing: function autoSizing(val) {
@@ -748,6 +748,10 @@ var component = { render: function render() {
748748
},
749749

750750
methods: {
751+
emitEvent: function emitEvent() {
752+
// console.log(args[0])
753+
this.$emit.apply(this, arguments);
754+
},
751755
getCanvas: function getCanvas() {
752756
return this.canvas;
753757
},
@@ -767,7 +771,7 @@ var component = { render: function render() {
767771
this._preventMovingToWhiteSpace();
768772
}
769773
if (this.imgData.startX !== oldX || this.imgData.startY !== oldY) {
770-
this.$emit(events.MOVE_EVENT);
774+
this.emitEvent(events.MOVE_EVENT);
771775
this._draw();
772776
}
773777
},
@@ -903,6 +907,7 @@ var component = { render: function render() {
903907
this.$refs.fileInput.click();
904908
},
905909
remove: function remove() {
910+
if (!this.imageSet) return;
906911
this._setPlaceholders();
907912

908913
var hadImage = this.img != null;
@@ -919,15 +924,14 @@ var component = { render: function render() {
919924
this.scaleRatio = null;
920925
this.userMetadata = null;
921926
this.imageSet = false;
922-
this.loading = false;
923927
this.chosenFile = null;
924928
if (this.video) {
925929
this.video.pause();
926930
this.video = null;
927931
}
928932

929933
if (hadImage) {
930-
this.$emit(events.IMAGE_REMOVE_EVENT);
934+
this.emitEvent(events.IMAGE_REMOVE_EVENT);
931935
}
932936
},
933937
addClipPlugin: function addClipPlugin(plugin) {
@@ -941,7 +945,7 @@ var component = { render: function render() {
941945
}
942946
},
943947
emitNativeEvent: function emitNativeEvent(evt) {
944-
this.$emit(evt.type, evt);
948+
this.emitEvent(evt.type, evt);
945949
},
946950
_setContainerSize: function _setContainerSize() {
947951
if (this.useAutoSizing) {
@@ -974,7 +978,7 @@ var component = { render: function render() {
974978
this.chosenFile = null;
975979
this._setInitial();
976980
if (!this.passive) {
977-
this.$emit(events.INIT_EVENT, this);
981+
this.emitEvent(events.INIT_EVENT, this);
978982
}
979983
},
980984
_setSize: function _setSize() {
@@ -1078,12 +1082,12 @@ var component = { render: function render() {
10781082
}
10791083
this.currentIsInitial = true;
10801084
if (u.imageLoaded(img)) {
1081-
// this.$emit(events.INITIAL_IMAGE_LOADED_EVENT)
1085+
// this.emitEvent(events.INITIAL_IMAGE_LOADED_EVENT)
10821086
this._onload(img, +img.dataset['exifOrientation'], true);
10831087
} else {
10841088
this.loading = true;
10851089
img.onload = function () {
1086-
// this.$emit(events.INITIAL_IMAGE_LOADED_EVENT)
1090+
// this.emitEvent(events.INITIAL_IMAGE_LOADED_EVENT)
10871091
_this4._onload(img, +img.dataset['exifOrientation'], true);
10881092
};
10891093

@@ -1096,6 +1100,9 @@ var component = { render: function render() {
10961100
var orientation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
10971101
var initial = arguments[2];
10981102

1103+
if (this.imageSet) {
1104+
this.remove();
1105+
}
10991106
this.originalImage = img;
11001107
this.img = img;
11011108

@@ -1106,7 +1113,7 @@ var component = { render: function render() {
11061113
this._setOrientation(orientation);
11071114

11081115
if (initial) {
1109-
this.$emit(events.INITIAL_IMAGE_LOADED_EVENT);
1116+
this.emitEvent(events.INITIAL_IMAGE_LOADED_EVENT);
11101117
}
11111118
},
11121119
_onVideoLoad: function _onVideoLoad(video, initial) {
@@ -1177,16 +1184,16 @@ var component = { render: function render() {
11771184

11781185
this.currentIsInitial = false;
11791186
this.loading = true;
1180-
this.$emit(events.FILE_CHOOSE_EVENT, file);
1187+
this.emitEvent(events.FILE_CHOOSE_EVENT, file);
11811188
this.chosenFile = file;
11821189
if (!this._fileSizeIsValid(file)) {
11831190
this.loading = false;
1184-
this.$emit(events.FILE_SIZE_EXCEED_EVENT, file);
1191+
this.emitEvent(events.FILE_SIZE_EXCEED_EVENT, file);
11851192
return false;
11861193
}
11871194
if (!this._fileTypeIsValid(file)) {
11881195
this.loading = false;
1189-
this.$emit(events.FILE_TYPE_MISMATCH_EVENT, file);
1196+
this.emitEvent(events.FILE_TYPE_MISMATCH_EVENT, file);
11901197
var type = file.type || file.name.toLowerCase().split('.').pop();
11911198
return false;
11921199
}
@@ -1220,7 +1227,7 @@ var component = { render: function render() {
12201227
fileData = null;
12211228
img.onload = function () {
12221229
_this6._onload(img, orientation);
1223-
_this6.$emit(events.NEW_IMAGE);
1230+
_this6.emitEvent(events.NEW_IMAGE_EVENT);
12241231
};
12251232
}
12261233
};
@@ -1493,8 +1500,8 @@ var component = { render: function render() {
14931500
this.emitNativeEvent(evt);
14941501
if (this.passive) return;
14951502
if (!this.fileDraggedOver || !u.eventHasFile(evt)) return;
1496-
if (this.hasImage() && this.replaceDrop) {
1497-
this.remove();
1503+
if (this.hasImage() && !this.replaceDrop) {
1504+
return;
14981505
}
14991506
this.fileDraggedOver = false;
15001507

@@ -1620,10 +1627,10 @@ var component = { render: function render() {
16201627
);
16211628
}
16221629

1623-
this.$emit(events.DRAW, ctx);
1630+
this.emitEvent(events.DRAW_EVENT, ctx);
16241631
if (!this.imageSet) {
16251632
this.imageSet = true;
1626-
this.$emit(events.NEW_IMAGE_DRAWN);
1633+
this.emitEvent(events.NEW_IMAGE_DRAWN_EVENT);
16271634
}
16281635
this.rotating = false;
16291636
},

dist/vue-croppa.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.

docs/dist/build.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.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<script src="static/vue.min.js"></script>
2727
<script src="static/vuetify.min.js"></script>
2828
<script async src="static/ei.js"></script>
29-
<script src="dist/build.js?v=1.2.0"></script>
29+
<script src="dist/build.js?v=1.3.7"></script>
3030
</body>
3131

3232
</html>

docs/src/croppa/vue-croppa.js

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

src/cropper.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export default {
319319
320320
methods: {
321321
emitEvent (...args) {
322-
console.log(args[0])
322+
// console.log(args[0])
323323
this.$emit(...args);
324324
},
325325

0 commit comments

Comments
 (0)