From 531750bb44844c31f2ea140078e68964a7c50923 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Sat, 6 Jan 2024 21:17:58 +0800 Subject: [PATCH] fix: disable zone tips when header and footer disabled #386 --- src/editor/core/zone/ZoneTip.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/editor/core/zone/ZoneTip.ts b/src/editor/core/zone/ZoneTip.ts index 555ef5a1a..0fa4d5dfd 100644 --- a/src/editor/core/zone/ZoneTip.ts +++ b/src/editor/core/zone/ZoneTip.ts @@ -27,17 +27,31 @@ export class ZoneTip { this.tipContent = tipContent this.isDisableMouseMove = true this.currentMoveZone = EditorZone.MAIN - - this._watchMouseMoveZoneChange() + // 监听区域 + const watchZones: EditorZone[] = [] + const { header, footer } = draw.getOptions() + if (!header.disabled) { + watchZones.push(EditorZone.HEADER) + } + if (!footer.disabled) { + watchZones.push(EditorZone.FOOTER) + } + if (watchZones.length) { + this._watchMouseMoveZoneChange(watchZones) + } } - private _watchMouseMoveZoneChange() { + private _watchMouseMoveZoneChange(watchZones: EditorZone[]) { this.pageContainer.addEventListener( 'mousemove', throttle((evt: MouseEvent) => { if (this.isDisableMouseMove) return if (evt.target instanceof HTMLCanvasElement) { const mousemoveZone = this.zone.getZoneByY(evt.offsetY) + if (!watchZones.includes(mousemoveZone)) { + this._updateZoneTip(false) + return + } this.currentMoveZone = mousemoveZone // 激活区域是正文,移动区域是页眉、页脚时绘制 this._updateZoneTip(