mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
parent
168ec281aa
commit
7a228b13e6
@ -21,9 +21,6 @@ export default class Rule extends EventEmitter {
|
|||||||
this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
|
this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
|
||||||
this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
|
this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
|
||||||
|
|
||||||
this.hGuides.on('changeGuides', this.hGuidesChangeGuidesHandler);
|
|
||||||
this.vGuides.on('changeGuides', this.vGuidesChangeGuidesHandler);
|
|
||||||
|
|
||||||
this.containerResizeObserver = new ResizeObserver(() => {
|
this.containerResizeObserver = new ResizeObserver(() => {
|
||||||
this.vGuides.resize();
|
this.vGuides.resize();
|
||||||
this.hGuides.resize();
|
this.hGuides.resize();
|
||||||
@ -129,8 +126,8 @@ export default class Rule extends EventEmitter {
|
|||||||
height: type === GuidesType.HORIZONTAL ? '30px' : '100%',
|
height: type === GuidesType.HORIZONTAL ? '30px' : '100%',
|
||||||
});
|
});
|
||||||
|
|
||||||
private createGuides = (type: GuidesType, defaultGuides: number[] = []): Guides =>
|
private createGuides = (type: GuidesType, defaultGuides: number[] = []): Guides => {
|
||||||
new Guides(this.container, {
|
const guides = new Guides(this.container, {
|
||||||
type,
|
type,
|
||||||
defaultGuides,
|
defaultGuides,
|
||||||
displayDragPos: true,
|
displayDragPos: true,
|
||||||
@ -141,6 +138,18 @@ export default class Rule extends EventEmitter {
|
|||||||
showGuides: this.isShowGuides,
|
showGuides: this.isShowGuides,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const changEventHandler = {
|
||||||
|
[GuidesType.HORIZONTAL]: this.hGuidesChangeGuidesHandler,
|
||||||
|
[GuidesType.VERTICAL]: this.vGuidesChangeGuidesHandler,
|
||||||
|
}[type];
|
||||||
|
|
||||||
|
if (changEventHandler) {
|
||||||
|
guides.on('changeGuides', changEventHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
return guides;
|
||||||
|
};
|
||||||
|
|
||||||
private hGuidesChangeGuidesHandler = (e: GuidesEvents['changeGuides']) => {
|
private hGuidesChangeGuidesHandler = (e: GuidesEvents['changeGuides']) => {
|
||||||
this.horizontalGuidelines = e.guides;
|
this.horizontalGuidelines = e.guides;
|
||||||
this.emit('change-guides', {
|
this.emit('change-guides', {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user