fix: 修复页面滚动高亮偏移的问题

This commit is contained in:
parisma 2022-03-31 19:31:27 +08:00 committed by jia000
parent f500e51933
commit 6a46f98766
3 changed files with 11 additions and 1 deletions

View File

@ -61,7 +61,7 @@ export default class StageCore extends EventEmitter {
this.renderer = new StageRender({ core: this });
this.mask = new StageMask({ core: this });
this.dr = new StageDragResize({ core: this, container: this.mask.content });
this.highlightLayer = new StageHighlight({ core: this, container: this.mask.content });
this.highlightLayer = new StageHighlight({ core: this, container: this.mask.wrapper });
this.renderer.on('runtime-ready', (runtime: Runtime) => this.emit('runtime-ready', runtime));
this.renderer.on('page-el-update', (el: HTMLElement) => this.mask?.observe(el));

View File

@ -46,6 +46,15 @@ export default class StageHighlight extends EventEmitter {
this.moveable?.destroy();
this.moveable = new Moveable(this.container, {
target: this.target,
scrollable: true,
origin: true,
zoom: 1,
bounds: {
top: 0,
left: 0,
right: this.container.clientWidth,
bottom: this.container.clientHeight,
},
});
}

View File

@ -240,6 +240,7 @@ export default class StageMask extends Rule {
};
private mouseWheelHandler = (event: WheelEvent) => {
this.emit('clearHighlight');
if (!this.page) throw new Error('page 未初始化');
const { deltaY, deltaX } = event;