Skip to content

Commit

Permalink
fix: reload layout when double clicking on panel resizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonella Sgarlatta committed Jun 2, 2021
1 parent de31fe7 commit 595b44d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
15 changes: 9 additions & 6 deletions app/assets/javascripts/directives/views/panelResizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PanelResizerCtrl implements PanelResizerScope {
index!: number
minWidth!: number
onResizeFinish!: () => ResizeFinishCallback
onMouseMoveEvent?: () => () => void
onWidthEvent?: () => () => void
panelId!: string
property!: PanelSide

Expand Down Expand Up @@ -104,7 +104,7 @@ class PanelResizerCtrl implements PanelResizerScope {

$onDestroy() {
(this.onResizeFinish as any) = undefined;
(this.onMouseMoveEvent as any) = undefined;
(this.onWidthEvent as any) = undefined;
(this.control as any) = undefined;
window.removeEventListener(WINDOW_EVENT_RESIZE, this.handleResize);
document.removeEventListener(MouseEventType.Move, this.onMouseMove);
Expand Down Expand Up @@ -189,6 +189,9 @@ class PanelResizerCtrl implements PanelResizerScope {
addDoubleClickHandler() {
this.resizerColumn.ondblclick = () => {
this.$timeout(() => {
if (this.onWidthEvent) {
this.onWidthEvent()();
}
const preClickCollapseState = this.isCollapsed();
if (preClickCollapseState) {
this.setWidth(this.widthBeforeLastDblClick || this.defaultWidth);
Expand Down Expand Up @@ -245,9 +248,6 @@ class PanelResizerCtrl implements PanelResizerScope {
return;
}
event.preventDefault();
if (this.onMouseMoveEvent) {
this.onMouseMoveEvent()();
}
if (this.property && this.property === PanelSide.Left) {
this.handleLeftEvent(event);
} else {
Expand All @@ -256,6 +256,9 @@ class PanelResizerCtrl implements PanelResizerScope {
}

handleWidthEvent(event?: MouseEvent) {
if (this.onWidthEvent) {
this.onWidthEvent()();
}
let x;
if (event) {
x = event!.clientX;
Expand Down Expand Up @@ -393,7 +396,7 @@ export class PanelResizer extends WebDirective {
index: '=',
minWidth: '=',
onResizeFinish: '&',
onMouseMoveEvent: '&',
onWidthEvent: '&',
panelId: '=',
property: '='
};
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/notes/notes-view.pug
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,6 @@
default-width="300"
hoverable="true"
on-resize-finish="self.onPanelResize"
on-mouse-move-event="self.onPanelMouseMoveEvent"
on-width-event="self.onPanelWidthEvent"
panel-id="'notes-column'"
)
7 changes: 4 additions & 3 deletions app/assets/javascripts/views/notes/notes_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
};
this.onWindowResize = this.onWindowResize.bind(this);
this.onPanelResize = this.onPanelResize.bind(this);
this.onPanelMouseMoveEvent = this.onPanelMouseMoveEvent.bind(this);
this.onPanelWidthEvent = this.onPanelWidthEvent.bind(this);
window.addEventListener('resize', this.onWindowResize, true);
this.registerKeyboardShortcuts();
this.autorun(async () => {
Expand Down Expand Up @@ -134,7 +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.onPanelMouseMoveEvent as any) = undefined;
(this.onPanelWidthEvent as any) = undefined;
this.newNoteKeyObserver();
this.nextNoteKeyObserver();
this.previousNoteKeyObserver();
Expand Down Expand Up @@ -649,6 +649,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
__: boolean,
isCollapsed: boolean
) {
this.appState.activeNote.reloadTagsContainerMaxWidth();
this.application.setPreference(
PrefKey.NotesPanelWidth,
newWidth
Expand All @@ -659,7 +660,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
);
}

onPanelMouseMoveEvent(): void {
onPanelWidthEvent(): void {
this.appState.activeNote.reloadTagsContainerMaxWidth();
}

Expand Down

0 comments on commit 595b44d

Please sign in to comment.