Skip to content

Commit 84ed4c8

Browse files
committed
Improve feel of resize handles
1 parent 52cae4c commit 84ed4c8

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

etc/js/components/pages/entities/page.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
v-if="app_params.sidebar"
1919
:parent="rootEl"
2020
:column="sidebarSplitterColumn"
21+
:active="rootEl?.dragging === 'leftPane'"
2122
@mousedown="rootEl.startDragging('leftPane')"
2223
></splitter>
2324

@@ -32,6 +33,7 @@
3233
<splitter
3334
:parent="rootEl"
3435
:column="inspectorSplitterColumn"
36+
:active="rootEl?.dragging === 'rightPane'"
3537
@mousedown="rootEl.startDragging('rightPane')"
3638
></splitter>
3739

etc/js/components/widgets/pane-container.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const containerWidth = ref(0);
3636
const leftPaneWidth = ref(Number(localStorage.getItem(`${props.id}.leftPaneWidth`)) || defaultLeftPaneWidth);
3737
const rightPaneWidth = ref(Number(localStorage.getItem(`${props.id}.rightPaneWidth`)) || defaultRightPaneWidth);
3838
39-
let dragging = null; // 'sidebar' | 'inspector' | null
39+
const dragging = ref(null); // 'leftPane' | 'rightPane' | null
4040
let containerRect = null;
4141
4242
function clampLeftPane(width, totalInnerWidth) {
@@ -50,33 +50,35 @@ function clampRightPane(width, totalInnerWidth) {
5050
}
5151
5252
function onWindowMouseMove(e) {
53-
if (!dragging || !containerRect) return;
53+
if (!dragging.value || !containerRect) return;
5454
const totalInnerWidth = containerRect.width; // grid area width
5555
containerWidth.value = totalInnerWidth;
56-
if (dragging === 'leftPane') {
56+
if (dragging.value === 'leftPane') {
5757
const newWidth = clampLeftPane(e.clientX - containerRect.left, totalInnerWidth);
5858
leftPaneWidth.value = Math.round(newWidth);
5959
localStorage.setItem(`${props.id}.leftPaneWidth`, String(leftPaneWidth.value));
60-
} else if (dragging === 'rightPane') {
60+
} else if (dragging.value === 'rightPane') {
6161
const newWidth = clampRightPane(containerRect.right - e.clientX - 4, totalInnerWidth);
6262
rightPaneWidth.value = Math.round(newWidth);
6363
localStorage.setItem(`${props.id}.rightPaneWidth`, String(rightPaneWidth.value));
6464
}
65-
updateCenterHidden(dragging === 'rightPane');
65+
updateCenterHidden(dragging.value === 'rightPane');
6666
// Notify canvas to resize while dragging
6767
window.dispatchEvent(new Event('resize'));
6868
}
6969
7070
function onWindowMouseUp() {
71-
if (dragging) {
72-
dragging = null;
71+
if (dragging.value) {
72+
dragging.value = null;
7373
containerRect = null;
74+
document.body.style.cursor = '';
7475
}
7576
}
7677
7778
function startDragging(which) {
78-
dragging = which;
79+
dragging.value = which;
7980
containerRect = rootEl.value.getBoundingClientRect();
81+
document.body.style.cursor = 'col-resize';
8082
}
8183
8284
// Attach listeners on mount, remove on unmount
@@ -175,7 +177,7 @@ const gridStyle = computed(() => {
175177
}
176178
});
177179
178-
defineExpose({startDragging, centerPaneHidden});
180+
defineExpose({startDragging, centerPaneHidden, dragging});
179181
180182
</script>
181183

etc/js/components/widgets/splitter.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22

3-
<div class="vsplitter" :style="`grid-column: ${column}`"></div>
3+
<div class="vsplitter" :class="{active: active}" :style="`grid-column: ${column}`"></div>
44

55
</template>
66

@@ -12,7 +12,8 @@ export default { name: "splitter" };
1212
import { defineProps } from 'vue';
1313
1414
const props = defineProps({
15-
column: {type: Number, required: true, default: 0}
15+
column: {type: Number, required: true, default: 0},
16+
active: {type: Boolean, required: false, default: false}
1617
});
1718
1819
</script>
@@ -34,7 +35,8 @@ div.vsplitter {
3435
box-sizing: border-box;
3536
}
3637
37-
div.vsplitter:hover {
38+
div.vsplitter:hover,
39+
div.vsplitter.active {
3840
opacity: 0.7;
3941
}
4042

0 commit comments

Comments
 (0)