Fix redraw after zoom change
Resize first, then repaint. The Range.getClientRects() is returning funny coordinates before resize.
This commit is contained in:
parent
32690de8a7
commit
2dd06fcef4
35
service.js
35
service.js
@ -976,23 +976,6 @@ class BesService {
|
|||||||
this.disableMutationObserver()
|
this.disableMutationObserver()
|
||||||
|
|
||||||
const styles = window.getComputedStyle(this.hostElement)
|
const styles = window.getComputedStyle(this.hostElement)
|
||||||
this.textFont = styles.fontFamily
|
|
||||||
|
|
||||||
// Resize canvas if needed.
|
|
||||||
this.canvasPanel.style.width = `${this.hostElement.scrollWidth}px`
|
|
||||||
this.canvasPanel.style.height = `${this.hostElement.scrollHeight}px`
|
|
||||||
const dpr = window.devicePixelRatio
|
|
||||||
const canvasPanelRect = this.canvasPanel.getBoundingClientRect()
|
|
||||||
const newCanvasWidth = Math.round(canvasPanelRect.width * dpr)
|
|
||||||
const newCanvasHeight = Math.round(canvasPanelRect.height * dpr)
|
|
||||||
if (
|
|
||||||
this.canvasPanel.width !== newCanvasWidth ||
|
|
||||||
this.canvasPanel.height !== newCanvasHeight
|
|
||||||
) {
|
|
||||||
this.canvasPanel.width = newCanvasWidth
|
|
||||||
this.canvasPanel.height = newCanvasHeight
|
|
||||||
this.redrawAllMistakeMarkup()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: Firefox is not happy when syncing all margins at once.
|
// Note: Firefox is not happy when syncing all margins at once.
|
||||||
this.scrollPanel.style.marginLeft = styles.marginLeft
|
this.scrollPanel.style.marginLeft = styles.marginLeft
|
||||||
@ -1016,6 +999,24 @@ class BesService {
|
|||||||
this.scrollPanel.style.height = `${hostRect.height}px`
|
this.scrollPanel.style.height = `${hostRect.height}px`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.textFont = styles.fontFamily
|
||||||
|
|
||||||
|
// Resize canvas if needed.
|
||||||
|
this.canvasPanel.style.width = `${this.hostElement.scrollWidth}px`
|
||||||
|
this.canvasPanel.style.height = `${this.hostElement.scrollHeight}px`
|
||||||
|
const dpr = window.devicePixelRatio
|
||||||
|
const canvasPanelRect = this.canvasPanel.getBoundingClientRect()
|
||||||
|
const newCanvasWidth = Math.round(canvasPanelRect.width * dpr)
|
||||||
|
const newCanvasHeight = Math.round(canvasPanelRect.height * dpr)
|
||||||
|
if (
|
||||||
|
this.canvasPanel.width !== newCanvasWidth ||
|
||||||
|
this.canvasPanel.height !== newCanvasHeight
|
||||||
|
) {
|
||||||
|
this.canvasPanel.width = newCanvasWidth
|
||||||
|
this.canvasPanel.height = newCanvasHeight
|
||||||
|
this.redrawAllMistakeMarkup()
|
||||||
|
}
|
||||||
|
|
||||||
this.enableMutationObserver()
|
this.enableMutationObserver()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user