mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-22 14:59:59 +08:00
fix(stage): drag的时候不update width height
This commit is contained in:
parent
8e2d83fec9
commit
30ad8502c4
@ -178,7 +178,7 @@ export default class StageDragResize extends EventEmitter {
|
|||||||
})
|
})
|
||||||
.on('resizeEnd', () => {
|
.on('resizeEnd', () => {
|
||||||
this.dragStatus = ActionStatus.END;
|
this.dragStatus = ActionStatus.END;
|
||||||
this.drag();
|
this.update(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ export default class StageDragResize extends EventEmitter {
|
|||||||
this.sort();
|
this.sort();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.drag();
|
this.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,19 +265,19 @@ export default class StageDragResize extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private drag(): void {
|
private update(isResize = false): void {
|
||||||
const rect = this.moveable!.getRect();
|
const rect = this.moveable!.getRect();
|
||||||
const offset =
|
const offset =
|
||||||
this.mode === Mode.SORTABLE ? { left: 0, top: 0 } : getAbsolutePosition(this.target as HTMLElement, rect);
|
this.mode === Mode.SORTABLE ? { left: 0, top: 0 } : getAbsolutePosition(this.target as HTMLElement, rect);
|
||||||
|
|
||||||
|
const left = this.calcValueByFontsize(offset.left);
|
||||||
|
const top = this.calcValueByFontsize(offset.top);
|
||||||
|
const width = this.calcValueByFontsize(rect.width);
|
||||||
|
const height = this.calcValueByFontsize(rect.height);
|
||||||
|
|
||||||
this.emit('update', {
|
this.emit('update', {
|
||||||
el: this.target,
|
el: this.target,
|
||||||
style: {
|
style: isResize ? { left, top, width, height } : { left, top },
|
||||||
left: this.calcValueByFontsize(offset.left),
|
|
||||||
top: this.calcValueByFontsize(offset.top),
|
|
||||||
width: this.calcValueByFontsize(rect.width),
|
|
||||||
height: this.calcValueByFontsize(rect.height),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,14 +338,6 @@ export default class StageDragResize extends EventEmitter {
|
|||||||
moveableOptions = moveableOptions(this.core);
|
moveableOptions = moveableOptions(this.core);
|
||||||
}
|
}
|
||||||
|
|
||||||
const boundsOptions = {
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: this.container.clientWidth,
|
|
||||||
bottom: this.container.clientHeight,
|
|
||||||
...(moveableOptions.bounds || {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
origin: true,
|
origin: true,
|
||||||
@ -362,7 +354,13 @@ export default class StageDragResize extends EventEmitter {
|
|||||||
horizontalGuidelines: this.horizontalGuidelines,
|
horizontalGuidelines: this.horizontalGuidelines,
|
||||||
verticalGuidelines: this.verticalGuidelines,
|
verticalGuidelines: this.verticalGuidelines,
|
||||||
|
|
||||||
bounds: boundsOptions,
|
bounds: {
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: this.container.clientWidth,
|
||||||
|
bottom: this.container.clientHeight,
|
||||||
|
...(moveableOptions.bounds || {}),
|
||||||
|
},
|
||||||
...options,
|
...options,
|
||||||
...moveableOptions,
|
...moveableOptions,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user