Skip to content

Commit

Permalink
refactor: verticalLayout dbclick logic & apply LSB minWidth
Browse files Browse the repository at this point in the history
Signed-off-by: daeyeon ko <[email protected]>
  • Loading branch information
kkdy21 committed Dec 17, 2024
1 parent 90b3514 commit ee8dd02
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ watch(() => props.breadcrumbs, () => {
ref="contentRef"
class="vertical-page-layout"
:width="width"
:min-width="240"
:enable-double-click-resize="state.menuId === MENU_ID.METRIC_EXPLORER"
v-on="$listeners"
>
Expand Down
28 changes: 24 additions & 4 deletions packages/mirinae/src/layouts/vertical-layout/PVerticalLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,20 @@ const state = reactive({
const leftLayoutContentBox = ref<null|HTMLElement>(null);
const resize = (delta : number) => {
state.width = delta;
};
const resize = (delta: number) => {
const minimumWidth = props.minWidth;
const maximumWidth = props.maxWidth;
if (Number.isNaN(delta)) {
return;
}
const newWidth = Math.min(Math.max(delta, minimumWidth), maximumWidth);
if (state.width !== newWidth) {
state.width = newWidth;
}
};
/* Resizing */
const isResizing = (event) => {
if (state.resizing) {
Expand Down Expand Up @@ -134,7 +144,17 @@ const handleControllerDoubleClick = () => {
const minimumWidth = props.minWidth;
const maximumWidth = props.maxWidth;
if (state.width <= minimumWidth + (maximumWidth - minimumWidth) / 2) {
if (state.width === maximumWidth) {
resize(minimumWidth);
return;
}
if (state.width === minimumWidth) {
resize(maximumWidth);
return;
}
if (state.width <= (maximumWidth + minimumWidth) / 2) {
resize(maximumWidth);
} else {
resize(minimumWidth);
Expand Down

0 comments on commit ee8dd02

Please sign in to comment.