mirror of
https://github.com/zadam/trilium.git
synced 2025-01-14 19:19:28 +08:00
fix: correct note-map resizing
This commit is contained in:
parent
2e9ce962df
commit
6612a3a550
2 changed files with 18 additions and 4 deletions
|
@ -55,7 +55,14 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||
this.$container = this.$widget.find(".note-map-container");
|
||||
this.$styleResolver = this.$widget.find('.style-resolver');
|
||||
|
||||
window.addEventListener('resize', () => this.setDimensions(), false);
|
||||
|
||||
try {
|
||||
new ResizeObserver(() => this.setDimensions()).observe(this.$container[0])
|
||||
} catch (error) {
|
||||
window.addEventListener('resize', () => this.setDimensions(), false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.$widget.find(".map-type-switcher button").on("click", async e => {
|
||||
const type = $(e.target).closest("button").attr("data-type");
|
||||
|
|
|
@ -87,8 +87,8 @@ export default class NoteMapRibbonWidget extends NoteContextAwareWidget {
|
|||
this.noteMapWidget.setDimensions();
|
||||
});
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
if (!this.graph) { // no graph has been even rendered
|
||||
const handleResize = () => {
|
||||
if (!this.noteMapWidget.graph) { // no graph has been even rendered
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,14 @@ export default class NoteMapRibbonWidget extends NoteContextAwareWidget {
|
|||
else if (this.openState === 'small') {
|
||||
this.setSmallSize();
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
try {
|
||||
new ResizeObserver(handleResize).observe(this.$widget[0])
|
||||
} catch (error) {
|
||||
window.addEventListener('resize', handleResize, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setSmallSize() {
|
||||
|
|
Loading…
Reference in a new issue