fix: position header and footer zone

pr675
Hufe921 3 years ago
parent 45a17ba756
commit ca5c4be9c3

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

Loading…
Cancel
Save