feat:adjust margins when paper direction change
This commit is contained in:
@@ -405,8 +405,7 @@ export class CommandAdapt {
|
|||||||
const { startIndex, endIndex } = this.range.getRange()
|
const { startIndex, endIndex } = this.range.getRange()
|
||||||
if (!~startIndex && !~endIndex) return
|
if (!~startIndex && !~endIndex) return
|
||||||
const elementList = this.draw.getElementList()
|
const elementList = this.draw.getElementList()
|
||||||
const { width, margins } = this.options
|
const innerWidth = this.draw.getInnerWidth()
|
||||||
const innerWidth = width - margins[1] - margins[3]
|
|
||||||
// colgroup
|
// colgroup
|
||||||
const colgroup: IColgroup[] = []
|
const colgroup: IColgroup[] = []
|
||||||
const colWidth = innerWidth / col
|
const colWidth = innerWidth / col
|
||||||
@@ -1460,7 +1459,7 @@ export class CommandAdapt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getPaperMargin(): number[] {
|
public getPaperMargin(): number[] {
|
||||||
return this.draw.getOriginalMargins()
|
return this.options.margins
|
||||||
}
|
}
|
||||||
|
|
||||||
public setPaperMargin(payload: IMargin) {
|
public setPaperMargin(payload: IMargin) {
|
||||||
|
|||||||
@@ -225,16 +225,20 @@ export class Draw {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getOriginalInnerWidth(): number {
|
public getOriginalInnerWidth(): number {
|
||||||
const { width, margins } = this.options
|
const width = this.getOriginalWidth()
|
||||||
|
const margins = this.getOriginalMargins()
|
||||||
return width - margins[1] - margins[3]
|
return width - margins[1] - margins[3]
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMargins(): IMargin {
|
public getMargins(): IMargin {
|
||||||
return <IMargin>this.options.margins.map(m => m * this.options.scale)
|
return <IMargin>this.getOriginalMargins().map(m => m * this.options.scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
public getOriginalMargins(): number[] {
|
public getOriginalMargins(): number[] {
|
||||||
return this.options.margins
|
const { margins, paperDirection } = this.options
|
||||||
|
return paperDirection === PaperDirection.VERTICAL
|
||||||
|
? margins
|
||||||
|
: [margins[1], margins[2], margins[3], margins[0]]
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPageGap(): number {
|
public getPageGap(): number {
|
||||||
|
|||||||
Reference in New Issue
Block a user