提交 36ebad8d 编写于 作者: bo.dang's avatar bo.dang

Merge branch 'dev-circle-live-20200715' into 'release'

裁剪优化,code review:bo.dang



See merge request !200
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
</div> </div>
</template> </template>
<script> <script>
import Cropper from 'cropperjs' let vm = null;
// import Cropper from 'cropperjs'
import Cropper from "../../utils/cropperjs/cropper";
import 'cropperjs/dist/cropper.min.css' import 'cropperjs/dist/cropper.min.css'
export default { export default {
name: 'rc-cropper2', name: 'rc-cropper2',
...@@ -26,6 +28,9 @@ ...@@ -26,6 +28,9 @@
required: true required: true
}, },
}, },
created() {
vm = this;
},
data () { data () {
return { return {
cropper: null, cropper: null,
...@@ -53,7 +58,7 @@ ...@@ -53,7 +58,7 @@
// int_x = 800/_this.cropOption.cvWidth; // int_x = 800/_this.cropOption.cvWidth;
// } // }
// //
// let int_y = _this.cropOption.cvHeight/800; // let int_y = _this.cropOption.cvHeight/540;
// if(int_y >= 1){ // if(int_y >= 1){
// int_y = 540/_this.cropOption.cvHeight; // int_y = 540/_this.cropOption.cvHeight;
// } // }
...@@ -124,9 +129,9 @@ ...@@ -124,9 +129,9 @@
highlight: true, highlight: true,
cropBoxMovable: true, cropBoxMovable: true,
zoomable: true, zoomable: true,
cropBoxResizable: this.cropOption.cropBoxResizable,//是否显示等比例缩放 cropBoxResizable: vm.cropOption.cropBoxResizable,//是否显示等比例缩放
minCropBoxWidth: this.cropOption.minCropBoxWidth,// 剪切区域的最小宽度 minCropBoxWidth: vm.cropOption.minCropBoxWidth,// 剪切区域的最小宽度
minCropBoxHeight: this.cropOption.minCropBoxHeight, // 剪切区域的最小高度 minCropBoxHeight: vm.cropOption.minCropBoxHeight, // 剪切区域的最小高度
// minContainerHeight: 500, // minContainerHeight: 500,
// minCanvasHeight: 500, // minCanvasHeight: 500,
restore: true, restore: true,
...@@ -135,10 +140,10 @@ ...@@ -135,10 +140,10 @@
aspectRatio: this.cropOption.aspectRatio,// 显示等比例缩放的比例 aspectRatio: this.cropOption.aspectRatio,// 显示等比例缩放的比例
ready: () => { ready: () => {
this.cropper.setData({ this.cropper.setData({
x: this.cropOption.offset_x, x: vm.cropOption.offset_x,
y: this.cropOption.offset_y, y: vm.cropOption.offset_y,
width: this.cropOption.width, width: vm.cropOption.width,
height: this.cropOption.height height: vm.cropOption.height
}) })
// this.cropper.setCropBoxData({ // this.cropper.setCropBoxData({
// width: 750, // width: 750,
...@@ -149,6 +154,7 @@ ...@@ -149,6 +154,7 @@
const imageData = this.cropper.getImageData(); const imageData = this.cropper.getImageData();
const canvasData = this.cropper.getCanvasData(); const canvasData = this.cropper.getCanvasData();
const cropBoxData = this.cropper.getCropBoxData();
console.log("imageData width:" + imageData.width); console.log("imageData width:" + imageData.width);
console.log("imageData height:" + imageData.height); console.log("imageData height:" + imageData.height);
console.log("imageData naturalWidth:" + imageData.naturalWidth); console.log("imageData naturalWidth:" + imageData.naturalWidth);
...@@ -157,6 +163,8 @@ ...@@ -157,6 +163,8 @@
console.log("canvasData naturalHeight:" + canvasData.naturalHeight); console.log("canvasData naturalHeight:" + canvasData.naturalHeight);
console.log("canvasData width:" + canvasData.width); console.log("canvasData width:" + canvasData.width);
console.log("canvasData height:" + canvasData.height); console.log("canvasData height:" + canvasData.height);
console.log("cropBoxData width:" + cropBoxData.width);
console.log("cropBoxData height:" + cropBoxData.height);
// this.cropper.zoomTo(-0.2); // this.cropper.zoomTo(-0.2);
const containerData = this.cropper.getContainerData(); const containerData = this.cropper.getContainerData();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册