1
1
/*
2
- * vue-croppa v1.3.3
2
+ * vue-croppa v1.3.4
3
3
* https://github.com/zhanziyang/vue-croppa
4
4
*
5
5
* Copyright (c) 2018 zhanziyang
@@ -621,6 +621,9 @@ var component = { render: function render() {
621
621
622
622
this . _autoSizingInit ( ) ;
623
623
} ,
624
+ beforeDestroy : function beforeDestroy ( ) {
625
+ this . _autoSizingRemove ( ) ;
626
+ } ,
624
627
625
628
626
629
watch : {
@@ -931,26 +934,33 @@ var component = { render: function render() {
931
934
emitNativeEvent : function emitNativeEvent ( evt ) {
932
935
this . $emit ( evt . type , evt ) ;
933
936
} ,
937
+ _setContainerSize : function _setContainerSize ( ) {
938
+ if ( this . $refs . wrapper && getComputedStyle ) {
939
+ this . realWidth = + getComputedStyle ( this . $refs . wrapper ) . width . slice ( 0 , - 2 ) ;
940
+ this . realHeight = + getComputedStyle ( this . $refs . wrapper ) . height . slice ( 0 , - 2 ) ;
941
+ }
942
+ } ,
934
943
_autoSizingInit : function _autoSizingInit ( ) {
935
- var _this3 = this ;
936
-
937
- var setContainerSize = function setContainerSize ( ) {
938
- if ( getComputedStyle && _this3 . $refs . wrapper instanceof Element ) {
939
- _this3 . realWidth = + getComputedStyle ( _this3 . $refs . wrapper ) . width . slice ( 0 , - 2 ) ;
940
- _this3 . realHeight = + getComputedStyle ( _this3 . $refs . wrapper ) . height . slice ( 0 , - 2 ) ;
941
- }
942
- } ;
943
- var useAutoSizing = this . autoSizing ;
944
- if ( useAutoSizing ) {
945
- setContainerSize ( ) ;
946
- window . addEventListener ( 'resize' , setContainerSize ) ;
944
+ if ( this . useAutoSizing ) {
945
+ this . _setContainerSize ( ) ;
946
+ window . addEventListener ( 'resize' , this . _setContainerSize ) ;
947
+ }
948
+ } ,
949
+ _autoSizingRemove : function _autoSizingRemove ( ) {
950
+ if ( this . useAutoSizing ) {
951
+ window . removeEventListener ( 'resize' , this . _setContainerSize ) ;
947
952
}
948
953
} ,
949
954
_initialize : function _initialize ( ) {
950
955
this . canvas = this . $refs . canvas ;
951
956
this . _setSize ( ) ;
952
957
this . canvas . style . backgroundColor = ! this . canvasColor || this . canvasColor == 'default' ? 'transparent' : typeof this . canvasColor === 'string' ? this . canvasColor : '' ;
953
958
this . ctx = this . canvas . getContext ( '2d' ) ;
959
+ this . ctx . mozImageSmoothingEnabled = true ;
960
+ this . ctx . imageSmoothingQuality = "high" ;
961
+ this . ctx . webkitImageSmoothingEnabled = true ;
962
+ this . ctx . msImageSmoothingEnabled = true ;
963
+ this . ctx . imageSmoothingEnabled = true ;
954
964
this . originalImage = null ;
955
965
this . img = null ;
956
966
this . imageSet = false ;
@@ -991,7 +1001,7 @@ var component = { render: function render() {
991
1001
this . _setOrientation ( orientation ) ;
992
1002
} ,
993
1003
_setImagePlaceholder : function _setImagePlaceholder ( ) {
994
- var _this4 = this ;
1004
+ var _this3 = this ;
995
1005
996
1006
var img = void 0 ;
997
1007
if ( this . $slots . placeholder && this . $slots . placeholder [ 0 ] ) {
@@ -1007,7 +1017,7 @@ var component = { render: function render() {
1007
1017
if ( ! img ) return ;
1008
1018
1009
1019
var onLoad = function onLoad ( ) {
1010
- _this4 . ctx . drawImage ( img , 0 , 0 , _this4 . outputWidth , _this4 . outputHeight ) ;
1020
+ _this3 . ctx . drawImage ( img , 0 , 0 , _this3 . outputWidth , _this3 . outputHeight ) ;
1011
1021
} ;
1012
1022
1013
1023
if ( u . imageLoaded ( img ) ) {
@@ -1032,7 +1042,7 @@ var component = { render: function render() {
1032
1042
this . _setTextPlaceholder ( ) ;
1033
1043
} ,
1034
1044
_setInitial : function _setInitial ( ) {
1035
- var _this5 = this ;
1045
+ var _this4 = this ;
1036
1046
1037
1047
var src = void 0 ,
1038
1048
img = void 0 ;
@@ -1067,11 +1077,11 @@ var component = { render: function render() {
1067
1077
this . loading = true ;
1068
1078
img . onload = function ( ) {
1069
1079
// this.$emit(events.INITIAL_IMAGE_LOADED_EVENT)
1070
- _this5 . _onload ( img , + img . dataset [ 'exifOrientation' ] , true ) ;
1080
+ _this4 . _onload ( img , + img . dataset [ 'exifOrientation' ] , true ) ;
1071
1081
} ;
1072
1082
1073
1083
img . onerror = function ( ) {
1074
- _this5 . _setPlaceholders ( ) ;
1084
+ _this4 . _setPlaceholders ( ) ;
1075
1085
} ;
1076
1086
}
1077
1087
} ,
@@ -1093,7 +1103,7 @@ var component = { render: function render() {
1093
1103
}
1094
1104
} ,
1095
1105
_onVideoLoad : function _onVideoLoad ( video , initial ) {
1096
- var _this6 = this ;
1106
+ var _this5 = this ;
1097
1107
1098
1108
this . video = video ;
1099
1109
var canvas = document . createElement ( 'canvas' ) ;
@@ -1105,25 +1115,25 @@ var component = { render: function render() {
1105
1115
var ctx = canvas . getContext ( '2d' ) ;
1106
1116
this . loading = false ;
1107
1117
var drawFrame = function drawFrame ( initial ) {
1108
- if ( ! _this6 . video ) return ;
1109
- ctx . drawImage ( _this6 . video , 0 , 0 , videoWidth , videoHeight ) ;
1118
+ if ( ! _this5 . video ) return ;
1119
+ ctx . drawImage ( _this5 . video , 0 , 0 , videoWidth , videoHeight ) ;
1110
1120
var frame = new Image ( ) ;
1111
1121
frame . src = canvas . toDataURL ( ) ;
1112
1122
frame . onload = function ( ) {
1113
- _this6 . img = frame ;
1123
+ _this5 . img = frame ;
1114
1124
// this._placeImage()
1115
1125
if ( initial ) {
1116
- _this6 . _placeImage ( ) ;
1126
+ _this5 . _placeImage ( ) ;
1117
1127
} else {
1118
- _this6 . _draw ( ) ;
1128
+ _this5 . _draw ( ) ;
1119
1129
}
1120
1130
} ;
1121
1131
} ;
1122
1132
drawFrame ( true ) ;
1123
1133
var keepDrawing = function keepDrawing ( ) {
1124
- _this6 . $nextTick ( function ( ) {
1134
+ _this5 . $nextTick ( function ( ) {
1125
1135
drawFrame ( ) ;
1126
- if ( ! _this6 . video || _this6 . video . ended || _this6 . video . paused ) return ;
1136
+ if ( ! _this5 . video || _this5 . video . ended || _this5 . video . paused ) return ;
1127
1137
requestAnimationFrame ( keepDrawing ) ;
1128
1138
} ) ;
1129
1139
} ;
@@ -1156,7 +1166,7 @@ var component = { render: function render() {
1156
1166
this . _onNewFileIn ( file ) ;
1157
1167
} ,
1158
1168
_onNewFileIn : function _onNewFileIn ( file ) {
1159
- var _this7 = this ;
1169
+ var _this6 = this ;
1160
1170
1161
1171
this . currentIsInitial = false ;
1162
1172
this . loading = true ;
@@ -1185,11 +1195,11 @@ var component = { render: function render() {
1185
1195
video . src = fileData ;
1186
1196
fileData = null ;
1187
1197
if ( video . readyState >= video . HAVE_FUTURE_DATA ) {
1188
- _this7 . _onVideoLoad ( video ) ;
1198
+ _this6 . _onVideoLoad ( video ) ;
1189
1199
} else {
1190
1200
video . addEventListener ( 'canplay' , function ( ) {
1191
1201
console . log ( 'can play event' ) ;
1192
- _this7 . _onVideoLoad ( video ) ;
1202
+ _this6 . _onVideoLoad ( video ) ;
1193
1203
} , false ) ;
1194
1204
}
1195
1205
} else {
@@ -1202,8 +1212,8 @@ var component = { render: function render() {
1202
1212
img . src = fileData ;
1203
1213
fileData = null ;
1204
1214
img . onload = function ( ) {
1205
- _this7 . _onload ( img , orientation ) ;
1206
- _this7 . $emit ( events . NEW_IMAGE ) ;
1215
+ _this6 . _onload ( img , orientation ) ;
1216
+ _this6 . $emit ( events . NEW_IMAGE ) ;
1207
1217
} ;
1208
1218
}
1209
1219
} ;
@@ -1440,7 +1450,7 @@ var component = { render: function render() {
1440
1450
this . currentPointerCoord = null ;
1441
1451
} ,
1442
1452
_handleWheel : function _handleWheel ( evt ) {
1443
- var _this8 = this ;
1453
+ var _this7 = this ;
1444
1454
1445
1455
this . emitNativeEvent ( evt ) ;
1446
1456
if ( this . passive ) return ;
@@ -1453,7 +1463,7 @@ var component = { render: function render() {
1453
1463
this . zoom ( ! this . reverseScrollToZoom ) ;
1454
1464
}
1455
1465
this . $nextTick ( function ( ) {
1456
- _this8 . scrolling = false ;
1466
+ _this7 . scrolling = false ;
1457
1467
} ) ;
1458
1468
} ,
1459
1469
_handleDragEnter : function _handleDragEnter ( evt ) {
@@ -1524,7 +1534,7 @@ var component = { render: function render() {
1524
1534
}
1525
1535
} ,
1526
1536
_setOrientation : function _setOrientation ( ) {
1527
- var _this9 = this ;
1537
+ var _this8 = this ;
1528
1538
1529
1539
var orientation = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : 6 ;
1530
1540
var applyMetadata = arguments [ 1 ] ;
@@ -1536,8 +1546,8 @@ var component = { render: function render() {
1536
1546
// u.getRotatedImageData(useOriginal ? this.originalImage : this.img, orientation)
1537
1547
var _img = u . getRotatedImage ( useOriginal ? this . originalImage : this . img , orientation ) ;
1538
1548
_img . onload = function ( ) {
1539
- _this9 . img = _img ;
1540
- _this9 . _placeImage ( applyMetadata ) ;
1549
+ _this8 . img = _img ;
1550
+ _this8 . _placeImage ( applyMetadata ) ;
1541
1551
} ;
1542
1552
} else {
1543
1553
this . _placeImage ( applyMetadata ) ;
@@ -1573,13 +1583,13 @@ var component = { render: function render() {
1573
1583
this . ctx . fillRect ( 0 , 0 , this . outputWidth , this . outputHeight ) ;
1574
1584
} ,
1575
1585
_draw : function _draw ( ) {
1576
- var _this10 = this ;
1586
+ var _this9 = this ;
1577
1587
1578
1588
this . $nextTick ( function ( ) {
1579
1589
if ( typeof window !== 'undefined' && window . requestAnimationFrame ) {
1580
- requestAnimationFrame ( _this10 . _drawFrame ) ;
1590
+ requestAnimationFrame ( _this9 . _drawFrame ) ;
1581
1591
} else {
1582
- _this10 . _drawFrame ( ) ;
1592
+ _this9 . _drawFrame ( ) ;
1583
1593
}
1584
1594
} ) ;
1585
1595
} ,
@@ -1626,12 +1636,12 @@ var component = { render: function render() {
1626
1636
ctx . closePath ( ) ;
1627
1637
} ,
1628
1638
_createContainerClipPath : function _createContainerClipPath ( ) {
1629
- var _this11 = this ;
1639
+ var _this10 = this ;
1630
1640
1631
1641
this . _clipPathFactory ( 0 , 0 , this . outputWidth , this . outputHeight ) ;
1632
1642
if ( this . clipPlugins && this . clipPlugins . length ) {
1633
1643
this . clipPlugins . forEach ( function ( func ) {
1634
- func ( _this11 . ctx , 0 , 0 , _this11 . outputWidth , _this11 . outputHeight ) ;
1644
+ func ( _this10 . ctx , 0 , 0 , _this10 . outputWidth , _this10 . outputHeight ) ;
1635
1645
} ) ;
1636
1646
}
1637
1647
} ,
@@ -1663,7 +1673,7 @@ var component = { render: function render() {
1663
1673
ctx . restore ( ) ;
1664
1674
} ,
1665
1675
_applyMetadata : function _applyMetadata ( ) {
1666
- var _this12 = this ;
1676
+ var _this11 = this ;
1667
1677
1668
1678
if ( ! this . userMetadata ) return ;
1669
1679
var _userMetadata = this . userMetadata ,
@@ -1685,7 +1695,7 @@ var component = { render: function render() {
1685
1695
}
1686
1696
1687
1697
this . $nextTick ( function ( ) {
1688
- _this12 . userMetadata = null ;
1698
+ _this11 . userMetadata = null ;
1689
1699
} ) ;
1690
1700
} ,
1691
1701
onDimensionChange : function onDimensionChange ( ) {
0 commit comments