Commit d3aa849e authored by 李维's avatar 李维

dev commit

parent eb1bd05c
...@@ -507,8 +507,8 @@ export class HotZoneImageItem extends MySprite { ...@@ -507,8 +507,8 @@ export class HotZoneImageItem extends MySprite {
arrowTop; arrowTop;
arrowRight; arrowRight;
init(image_url = null, initWidth, initHeight, callback?){ init(image_url = null, callback?){
this.showImage(image_url, initWidth, initHeight, (img)=>{ this.showImage(image_url, (img)=>{
callback && callback(img.width, img.height) callback && callback(img.width, img.height)
this.setSize(img.width*this.image.scaleX, img.height*this.image.scaleY) this.setSize(img.width*this.image.scaleX, img.height*this.image.scaleY)
this.lineDashFlag = true; this.lineDashFlag = true;
...@@ -553,7 +553,7 @@ export class HotZoneImageItem extends MySprite { ...@@ -553,7 +553,7 @@ export class HotZoneImageItem extends MySprite {
this.label.visible = false; this.label.visible = false;
} }
showImage(image_url = null, initWidth, initHeight, callback) { showImage(image_url = null, callback) {
this.loadImage(image_url).then((img)=>{ this.loadImage(image_url).then((img)=>{
if(this.image){ if(this.image){
this.removeChild(this.image) this.removeChild(this.image)
......
...@@ -99,8 +99,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges { ...@@ -99,8 +99,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
ngOnInit() { ngOnInit() {
this.initListener(); this.initListener();
console.log("init")
// this.init();
this.update(); this.update();
} }
...@@ -113,10 +111,7 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges { ...@@ -113,10 +111,7 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
} }
onBackgroundUploadSuccess(e) { onBackgroundUploadSuccess(e) {
console.log('e: ', e);
this.bgItem.url = e.url; this.bgItem.url = e.url;
this.refreshBackground(); this.refreshBackground();
} }
...@@ -151,13 +146,14 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges { ...@@ -151,13 +146,14 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
} }
onImgUploadSuccessByImg(e, item) { onImgUploadSuccessByImg(e, item) {
item.init(e.url) item.init(e.url,(w, h)=>{
item.setScaleXY(Math.min(100 / w, 150 / h))
})
item.pic_url = e.url; item.pic_url = e.url;
this.refreshImage (item); this.refreshImage (item);
} }
onAudioUploadSuccess(e, item) { onAudioUploadSuccess(e, item) {
console.log(e)
item.audio_url = e.url; item.audio_url = e.url;
} }
...@@ -192,20 +188,19 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges { ...@@ -192,20 +188,19 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
const itemH = 200; const itemH = 200;
const item = new HotZoneImageItem(this.ctx); const item = new HotZoneImageItem(this.ctx);
if(saveData){ if(saveData){
item.init(saveData.media.image_url, saveData.rect.width , saveData.rect.height, (w, h)=>{ item.init(saveData.media.image_url, (w, h)=>{
const saveRect = saveData.rect; const saveRect = saveData.rect;
item.scaleX = saveData.rect.width / w; item.scaleX = saveData.rect.width / w;
item.scaleY = saveData.rect.height / h; item.scaleY = saveData.rect.height / h;
item.x = saveRect.x // + saveRect.width / 2 ; item.x = saveRect.x
item.y = saveRect.y // + saveRect.height / 2; item.y = saveRect.y
if(saveData.media.image_url.indexOf("bg_200_200") == -1){ if(saveData.media.image_url.indexOf("bg_200_200") == -1){
item.image_url = saveData.media.image_url item.image_url = saveData.media.image_url
} }
}); });
item.audio_url = saveData.media.audio_url item.audio_url = saveData.media.audio_url
console.log(item)
}else{ }else{
item.init("assets/default/bg_200_200.png" , 200 , 200, ()=>{ item.init("assets/default/bg_200_200.png" , ()=>{
item.image_url = "assets/default/bg_200_200.png" item.image_url = "assets/default/bg_200_200.png"
}); });
} }
...@@ -313,7 +308,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges { ...@@ -313,7 +308,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
initImgArr() { initImgArr() {
console.log('this.imgItemArr: ', this.imgItemArr); console.log('this.imgItemArr: ', this.imgItemArr);
let curBgRect; let curBgRect;
if (this.bg) { if (this.bg) {
...@@ -404,37 +398,11 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges { ...@@ -404,37 +398,11 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
} else if (this.changeRightSizeFlag) { } else if (this.changeRightSizeFlag) {
this.changeRightSize(); this.changeRightSize();
} else { } else {
let addX = this.mx - this.oldPos.x; let addX = this.mx - this.oldPos.x;
let addY = this.my - this.oldPos.y; let addY = this.my - this.oldPos.y;
this.curItem.x += addX; this.curItem.x += addX;
this.curItem.y += addY; this.curItem.y += addY;
// if( !((this.curItem.y + (this.curItem.height)*this.curItem.scaleY)>300) && !(this.curItem.y<0) ){
// if( !((this.curItem.x + (this.curItem.width)*this.curItem.scaleX)>200) && !(this.curItem.x<0) ){
// let addX = this.mx - this.oldPos.x;
// let addY = this.my - this.oldPos.y;
// this.curItem.x += addX;
// this.curItem.y += addY;
// }else{
// if(this.curItem.x<0){
// this.curItem.x = 0;
// }else{
// this.curItem.x = 200-(this.curItem.width)*this.curItem.scaleX;
// }
// }
// }else{
// if(this.curItem.y<0){
// this.curItem.y = 0;
// }else{
// this.curItem.y = 300-(this.curItem.height)*this.curItem.scaleY;
// }
// }
console.log(this.curItem.y + (this.curItem.height)*this.curItem.scaleY)
} }
this.oldPos = {x: this.mx, y: this.my}; this.oldPos = {x: this.mx, y: this.my};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment