Skip to content

Commit

Permalink
fix: update pagebreak by methods on graph
Browse files Browse the repository at this point in the history
fix #13
  • Loading branch information
bubkoo committed Dec 19, 2019
1 parent 4b9e072 commit 30bdb90
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/x6/src/graph/pagebreak-accessor.ts
Expand Up @@ -17,13 +17,15 @@ export class PageBreakAccessor extends BaseGraph {
enablePageBreak() {
if (!this.isPageBreakEnabled()) {
this.options.pageBreak.enabled = true
this.sizeDidChange()
}
return this
}

disablePageBreak() {
if (this.isPageBreakEnabled()) {
this.options.pageBreak.enabled = false
this.sizeDidChange()
}
return this
}
Expand All @@ -47,6 +49,7 @@ export class PageBreakAccessor extends BaseGraph {
setPageBreakColor(color: string) {
if (this.getPageBreakColor() !== color) {
this.options.pageBreak.stroke = color
this.sizeDidChange()
}
return this
}
Expand All @@ -66,6 +69,7 @@ export class PageBreakAccessor extends BaseGraph {
setPageBreakDashed(dsahed: boolean) {
if (dsahed !== this.isPageBreakDashed()) {
this.options.pageBreak.dsahed = dsahed
this.sizeDidChange()
}
return this
}
Expand All @@ -85,6 +89,7 @@ export class PageBreakAccessor extends BaseGraph {
setPageBreakMinDist(minDist: number) {
if (minDist !== this.getPageBreakMinDist()) {
this.options.pageBreak.minDist = minDist
this.sizeDidChange()
}
return this
}
Expand Down
14 changes: 10 additions & 4 deletions packages/x6/src/graph/pagebreak-manager.ts
Expand Up @@ -6,7 +6,13 @@ export class PageBreakManager extends BaseManager {
protected verticalPageBreaks: Polyline[]
protected horizontalPageBreaks: Polyline[]

updatePageBreaks(visible: boolean, width: number, height: number) {}
updatePageBreaks(visible: boolean, width: number, height: number) {
if (this.graph.infinite) {
this.updatePageBreaksInfinite(visible, width, height)
} else {
this.updatePageBreaksNormal(visible, width, height)
}
}

updatePageBreaksNormal(visible: boolean, width: number, height: number) {
const s = this.view.scale
Expand Down Expand Up @@ -38,7 +44,7 @@ export class PageBreakManager extends BaseManager {
this.drawPageBreaks(false, vCount, pb, right, bottom, false)
}

updatePageBreaksInfinite(visible: boolean) {
updatePageBreaksInfinite(visible: boolean, width: number, height: number) {
const ps = this.view.scale * this.graph.pageScale
const fmt = this.graph.pageFormat
const gb = this.view.getBackgroundPageBounds()
Expand Down Expand Up @@ -67,11 +73,11 @@ export class PageBreakManager extends BaseManager {
infinite: boolean,
) {
if (horizontal) {
if (this.horizontalPageBreaks == null && count > 0) {
if (this.horizontalPageBreaks == null) {
this.horizontalPageBreaks = []
}
} else {
if (this.verticalPageBreaks == null && count > 0) {
if (this.verticalPageBreaks == null) {
this.verticalPageBreaks = []
}
}
Expand Down

0 comments on commit 30bdb90

Please sign in to comment.