fix: disable zone tips when header and footer disabled #386

pr675
Hufe921 2 years ago
parent 8c40c9ed33
commit 531750bb44

@ -27,17 +27,31 @@ export class ZoneTip {
this.tipContent = tipContent this.tipContent = tipContent
this.isDisableMouseMove = true this.isDisableMouseMove = true
this.currentMoveZone = EditorZone.MAIN 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( this.pageContainer.addEventListener(
'mousemove', 'mousemove',
throttle((evt: MouseEvent) => { throttle((evt: MouseEvent) => {
if (this.isDisableMouseMove) return if (this.isDisableMouseMove) return
if (evt.target instanceof HTMLCanvasElement) { if (evt.target instanceof HTMLCanvasElement) {
const mousemoveZone = this.zone.getZoneByY(evt.offsetY) const mousemoveZone = this.zone.getZoneByY(evt.offsetY)
if (!watchZones.includes(mousemoveZone)) {
this._updateZoneTip(false)
return
}
this.currentMoveZone = mousemoveZone this.currentMoveZone = mousemoveZone
// 激活区域是正文,移动区域是页眉、页脚时绘制 // 激活区域是正文,移动区域是页眉、页脚时绘制
this._updateZoneTip( this._updateZoneTip(

Loading…
Cancel
Save