feat(editor): 选中组件,组件自动滚动到视窗内

This commit is contained in:
roymondchen 2022-05-24 21:06:39 +08:00 committed by jia000
parent 91e2591495
commit 50937c2867
2 changed files with 12 additions and 0 deletions

View File

@ -155,6 +155,8 @@ export default class StageCore extends EventEmitter {
this.mask.setLayout(el);
this.dr.select(el, event);
this.mask.scrollIntoView(el);
this.selectedDom = el;
if (this.renderer.contentWindow) {

View File

@ -173,6 +173,16 @@ export default class StageMask extends Rule {
this.setMode(isFixedParent(el) ? Mode.FIXED : Mode.ABSOLUTE);
}
public scrollIntoView(el: HTMLElement): void {
if (this.mode === Mode.FIXED) return;
el.scrollIntoView();
if (!this.pageScrollParent) return;
this.scrollLeft = this.pageScrollParent.scrollLeft;
this.scrollTop = this.pageScrollParent.scrollTop;
this.scroll();
}
/**
*
*/