Browse Source

[修正] 背景图缩放 BUG修正

develop
陈鹏飞 4 years ago
parent
commit
658231441b
  1. 14
      src/app/ui/collection-tools/collection-tools.component.ts
  2. 8
      src/app/ui/collection-tools/panel.scss

14
src/app/ui/collection-tools/collection-tools.component.ts

@ -435,7 +435,6 @@ export class CollectionToolsComponent implements OnInit {
ngAfterViewInit(): void {
// 监听canvas组件选中素材事件
this.canvas.on("select",obj=>{
console.log(obj.assetData)
//选中素材属性注入函数
this.setAssetsProperty(obj.assetData)
})
@ -942,13 +941,24 @@ export class CollectionToolsComponent implements OnInit {
backGroundScale () {
let that = this
let dad = document.querySelector('.functionalDomainContent').clientWidth
let dadHeight = document.querySelector('.functionalDomainContent').clientHeight
let left = document.querySelector('.functionalDomainLeft').clientWidth
let right = document.querySelector('.functionalDomainRight').clientWidth
let imgWidth = dad - left - right//可是区域内 宽度
let img = new Image()
img.src = this.selectingSitePlan.imageUrl;
img.onload = function(){
img.width > imgWidth? that.canvas.setBackgroundScale(imgWidth/img.width) : null
if (img.height > dadHeight && img.width > imgWidth) {
let number = (dadHeight/img.height + imgWidth/img.width) / 2
that.canvas.setBackgroundScale(number-0.015)
return
} else if (img.height > dadHeight) {
that.canvas.setBackgroundScale((dadHeight/img.height)-0.01)
return
} else if (img.width > imgWidth) {
that.canvas.setBackgroundScale((imgWidth/img.width)-0.01)
return
}
};
}

8
src/app/ui/collection-tools/panel.scss

@ -201,7 +201,11 @@
//左侧功能区弹出框样式
.keyMargin {
width: 100%;
margin: 5px 0;
.mat-form-field {
width: 100%;
}
}
.submitBottom {
display: flex;
@ -210,12 +214,12 @@
justify-content: space-between; /* 水平居中 */
}
.functionalDomainContent {
width: 100%;
width: 300px;
height: 100%;
textarea {
border-radius: 5px;
border: 1px solid #999;
width: 180px;
width: 100%;
height: 120px;
resize:none;
}

Loading…
Cancel
Save