Merge pull request #3808 from soulsands/fix-resize

Fix: correct note-map resizing
This commit is contained in:
zadam 2023-04-06 21:28:01 +02:00 committed by GitHub
commit e6adf3a522
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View file

@ -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");

View file

@ -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() {