mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-16 18:09:22 +08:00
feat(stage): elementGuidelines可以配置
This commit is contained in:
parent
a320823992
commit
85164ec432
@ -166,16 +166,12 @@ export default class StageDragResize extends EventEmitter {
|
||||
|
||||
this.updateDragEl(el);
|
||||
|
||||
this.setElementGuidelines(el);
|
||||
|
||||
this.moveableOptions = this.getOptions({
|
||||
target: this.dragEl,
|
||||
});
|
||||
}
|
||||
|
||||
private setElementGuidelines(el: HTMLElement) {
|
||||
const nodes = el.parentElement?.children || [];
|
||||
|
||||
private setElementGuidelines(nodes: HTMLElement[]) {
|
||||
this.elementGuidelines.forEach((node) => {
|
||||
node.remove();
|
||||
});
|
||||
@ -186,7 +182,7 @@ export default class StageDragResize extends EventEmitter {
|
||||
|
||||
for (const node of nodes) {
|
||||
const { width, height } = node.getBoundingClientRect();
|
||||
if (node === el) continue;
|
||||
if (node === this.target) continue;
|
||||
const { left, top } = getOffset(node as HTMLElement);
|
||||
const elementGuideline = document.createElement('div');
|
||||
elementGuideline.style.cssText = `position: absolute;width: ${width}px;height: ${height}px;top: ${top}px;left: ${left}px`;
|
||||
@ -404,6 +400,14 @@ export default class StageDragResize extends EventEmitter {
|
||||
moveableOptions = moveableOptions(this.core);
|
||||
}
|
||||
|
||||
const elementGuidelines: any = moveableOptions.elementGuidelines || this.target.parentElement?.children || [];
|
||||
|
||||
this.setElementGuidelines(elementGuidelines);
|
||||
|
||||
if (moveableOptions.elementGuidelines) {
|
||||
delete moveableOptions.elementGuidelines;
|
||||
}
|
||||
|
||||
return {
|
||||
origin: false,
|
||||
rootContainer: this.core.container,
|
||||
|
Loading…
x
Reference in New Issue
Block a user