Skip to content

Commit ecdbfaf

Browse files
committed
feat: Implement sidebar resizer functionality for improved UI interaction
1 parent 6512e2b commit ecdbfaf

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,42 @@
14791479
// ============================================================================
14801480
// EVENTS
14811481
// ============================================================================
1482+
const initSidebarResizer = () => {
1483+
const handle = D.resizer;
1484+
const panel = D.side;
1485+
if (!handle || !panel) return;
1486+
1487+
const minWidth = panel.getBoundingClientRect().width;
1488+
const safeMax = Math.max(minWidth, window.innerWidth - 320);
1489+
let startX = 0;
1490+
let startWidth = panel.offsetWidth;
1491+
1492+
const onMove = e => {
1493+
const delta = e.clientX - startX;
1494+
let targetWidth = startWidth + delta;
1495+
if (targetWidth < minWidth) targetWidth = minWidth;
1496+
if (targetWidth > safeMax) targetWidth = safeMax;
1497+
panel.style.width = `${targetWidth}px`;
1498+
};
1499+
1500+
const stopDrag = () => {
1501+
document.removeEventListener('mousemove', onMove);
1502+
document.removeEventListener('mouseup', stopDrag);
1503+
document.body.style.cursor = '';
1504+
handle.classList.remove('active');
1505+
};
1506+
1507+
handle.addEventListener('mousedown', e => {
1508+
e.preventDefault();
1509+
startX = e.clientX;
1510+
startWidth = panel.offsetWidth;
1511+
document.body.style.cursor = 'ew-resize';
1512+
handle.classList.add('active');
1513+
document.addEventListener('mousemove', onMove);
1514+
document.addEventListener('mouseup', stopDrag);
1515+
});
1516+
};
1517+
14821518
const setup = () => {
14831519
console.log('Setting up event handlers...');
14841520
if (D.tog) D.tog.addEventListener('click', () => D.side && D.side.classList.toggle('collapsed'));
@@ -1569,6 +1605,7 @@
15691605
if (D.gen) D.gen.addEventListener('click', gen);
15701606
if (D.copy) D.copy.addEventListener('click', copyClip);
15711607
if (D.txt) D.txt.addEventListener('click', () => dl('txt'));
1608+
initSidebarResizer();
15721609
// Clear All button
15731610
const clearBtn = $('clearAll');
15741611
if (clearBtn) {

style.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
.sidebar-btn-icon {
1919
width: 20px;
2020
height: 20px;
21-
vertical-align: middle;
2221
margin-right: 8px;
2322
margin-bottom: 2px;
2423
filter: brightness(0) saturate(100%) invert(0);
@@ -36,7 +35,6 @@
3635
.context-btn-icon {
3736
width: 22px;
3837
height: 22px;
39-
vertical-align: middle;
4038
margin-right: 8px;
4139
margin-bottom: 2px;
4240
}

0 commit comments

Comments
 (0)