feat: use panel width event instead of ResizeObserver

This commit is contained in:
Antonella Sgarlatta
2021-05-31 12:59:35 -03:00
parent 7ac5856205
commit b7c2fa0b60
9 changed files with 185 additions and 110 deletions

View File

@@ -169,5 +169,6 @@
default-width="300"
hoverable="true"
on-resize-finish="self.onPanelResize"
on-width-event="self.onPanelWidthEvent"
panel-id="'notes-column'"
)

View File

@@ -93,6 +93,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
};
this.onWindowResize = this.onWindowResize.bind(this);
this.onPanelResize = this.onPanelResize.bind(this);
this.onPanelWidthEvent = this.onPanelWidthEvent.bind(this);
window.addEventListener('resize', this.onWindowResize, true);
this.registerKeyboardShortcuts();
this.autorun(async () => {
@@ -133,6 +134,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
window.removeEventListener('resize', this.onWindowResize, true);
(this.onWindowResize as any) = undefined;
(this.onPanelResize as any) = undefined;
(this.onPanelWidthEvent as any) = undefined;
this.newNoteKeyObserver();
this.nextNoteKeyObserver();
this.previousNoteKeyObserver();
@@ -408,7 +410,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
await this.appState.createEditor(title);
await this.flushUI();
await this.reloadNotes();
await this.appState.notes.reloadActiveNoteTags();
await this.appState.activeNote.reloadTags();
}
async handleTagChange(tag: SNTag) {
@@ -643,7 +645,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
onPanelResize(
newWidth: number,
_: number,
newLeft: number,
__: boolean,
isCollapsed: boolean
) {
@@ -657,6 +659,10 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
);
}
onPanelWidthEvent(): void {
this.appState.activeNote.reloadTagsContainerLayout();
}
paginate() {
this.notesToDisplay += this.pageSize;
this.reloadNotes();