Skip to content

Commit 94509d3

Browse files
authored
Merge pull request #435 from vizzuhq/fix-browser-zoom
Fixed redraw on browser zoom.
2 parents 9eddf3a + 6b75f9f commit 94509d3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
### Fixed
66

7+
- Fixed redraw on browser zoom (bug since 0.9.0).
78
- TypeScript definition fixed, measures can contain null values.
89

910
### Added
1011

1112
- Animation control object expose properties `position`, `direction`, `speed`
1213
and `playState` to be able to query the current state of the animation, and
13-
to be more conform with the Web Animation API. Old methods got deprecated.
14+
to be more conform with the Web Animation API.
1415

1516
## [0.9.1] - 2023-11-15
1617

src/apps/weblib/ts-api/htmlcanvas.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class HtmlCanvas implements Plugin {
2424
private _mainCanvas: HTMLCanvasElement
2525
private _context: CanvasRenderingContext2D
2626
private _resizeObserver: ResizeObserver
27+
private _resizeHandler: () => void
2728
private _prevUpdateHash: string = ''
2829
private _scaleFactor: number = 1
2930
private _cssWidth: number = 1
@@ -71,9 +72,14 @@ export class HtmlCanvas implements Plugin {
7172
this._context = ctx
7273
this.calcSize()
7374
this._resizeObserver = this._createResizeObserverFor(this._mainCanvas)
75+
this._resizeHandler = (): void => {
76+
this.onchange()
77+
}
78+
window.addEventListener('resize', this._resizeHandler)
7479
}
7580

7681
destruct(): void {
82+
window.removeEventListener('resize', this._resizeHandler)
7783
this._resizeObserver.disconnect()
7884
if (this._container) this._container.removeChild(this._mainCanvas)
7985
}

0 commit comments

Comments
 (0)