mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 11:39:37 +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.$container = this.$widget.find(".note-map-container");
|
||||||
this.$styleResolver = this.$widget.find('.style-resolver');
|
this.$styleResolver = this.$widget.find('.style-resolver');
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
new ResizeObserver(() => this.setDimensions()).observe(this.$container[0])
|
||||||
|
} catch (error) {
|
||||||
window.addEventListener('resize', () => this.setDimensions(), false);
|
window.addEventListener('resize', () => this.setDimensions(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.$widget.find(".map-type-switcher button").on("click", async e => {
|
this.$widget.find(".map-type-switcher button").on("click", async e => {
|
||||||
const type = $(e.target).closest("button").attr("data-type");
|
const type = $(e.target).closest("button").attr("data-type");
|
||||||
|
|
|
@ -87,8 +87,8 @@ export default class NoteMapRibbonWidget extends NoteContextAwareWidget {
|
||||||
this.noteMapWidget.setDimensions();
|
this.noteMapWidget.setDimensions();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('resize', () => {
|
const handleResize = () => {
|
||||||
if (!this.graph) { // no graph has been even rendered
|
if (!this.noteMapWidget.graph) { // no graph has been even rendered
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,14 @@ export default class NoteMapRibbonWidget extends NoteContextAwareWidget {
|
||||||
else if (this.openState === 'small') {
|
else if (this.openState === 'small') {
|
||||||
this.setSmallSize();
|
this.setSmallSize();
|
||||||
}
|
}
|
||||||
}, false);
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
new ResizeObserver(handleResize).observe(this.$widget[0])
|
||||||
|
} catch (error) {
|
||||||
|
window.addEventListener('resize', handleResize, false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setSmallSize() {
|
setSmallSize() {
|
||||||
|
|
Loading…
Reference in a new issue