fix: position header and footer zone

pr675
Hufe921 3 years ago
parent 45a17ba756
commit ca5c4be9c3

@ -332,30 +332,32 @@ export class Position {
} }
} }
if (!isLastArea) { if (!isLastArea) {
const mainLastLetterList = isMainActive // 页眉底部距离页面顶部距离
? lastLetterList const header = this.draw.getHeader()
: this.getOriginalMainPositionList().filter(p => p.isLastLetter && p.pageNo === positionNo) const headerBottomY = header.getHeaderTop() + header.getHeight()
const firstPosition = mainLastLetterList[0] // 页脚上部距离页面顶部距离
const lastPosition = mainLastLetterList[mainLastLetterList.length - 1] const footer = this.draw.getFooter()
const pageHeight = this.draw.getHeight()
const footerTopY = pageHeight - (footer.getFooterBottom() + footer.getHeight())
// 判断所属位置是否属于页眉页脚区域 // 判断所属位置是否属于页眉页脚区域
if (isMainActive) { if (isMainActive) {
// 页眉:当前位置小于第一行的上边距 // 页眉:当前位置小于页眉底部位置
if (y < firstPosition.coordinate.leftTop[1]) { if (y < headerBottomY) {
return { return {
index: -1, index: -1,
zone: EditorZone.HEADER zone: EditorZone.HEADER
} }
} }
// 页脚:当前位置大于最后一行的下边距 // 页脚:当前位置大于页脚顶部位置
if (y > lastPosition.coordinate.leftBottom[1]) { if (y > footerTopY) {
return { return {
index: -1, index: -1,
zone: EditorZone.FOOTER zone: EditorZone.FOOTER
} }
} }
} else { } else {
// main区域当前位置大于第一行的上边距 && 小于最后一行的下边距 // main区域当前位置小于页眉底部位置 && 大于页脚顶部位置
if (y >= firstPosition.coordinate.leftTop[1] && y <= lastPosition.coordinate.leftBottom[1]) { if (y <= footerTopY && y >= headerBottomY) {
return { return {
index: -1, index: -1,
zone: EditorZone.MAIN zone: EditorZone.MAIN

Loading…
Cancel
Save