Skip to content

Commit 8f711bb

Browse files
fbassoMarkoOleksiyenko
authored andcommitted
fix(drawer): onResizingChange sent after first resizing instead of mouse down
1 parent c88474c commit 8f711bb

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

core/src/components/drawer/drawer.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,16 @@ export const createDrawer: WidgetFactory<DrawerWidget> = createWidgetFactory('dr
450450
const isMinimized$ = writable(<boolean | undefined>undefined);
451451
const isMaximized$ = writable(<boolean | undefined>undefined);
452452

453+
/**
454+
* Sets the size of the drawer element and updates related state.
455+
*
456+
* This function updates the drawer's dimensions (width or height depending on orientation),
457+
* calculates the actual rendered size, and adjusts the minimized/maximized states
458+
*
459+
* @param size - The desired size in pixels for the drawer. Must be a non-negative number. Will be rounded to the nearest integer and clamped to a minimum of 0.
460+
*
461+
* @returns The actual rendered size of the drawer element in pixels after applying the style.
462+
*/
453463
function setSize(size: number) {
454464
const drawerElement = drawerElement$()!;
455465
const isVertical = isVertical$();
@@ -471,15 +481,22 @@ export const createDrawer: WidgetFactory<DrawerWidget> = createWidgetFactory('dr
471481
const clientXorY = isVertical ? 'clientY' : 'clientX';
472482
const startPos = event[clientXorY];
473483
const direction = direction$();
474-
onResizingChange$()(true);
484+
let isResizing = false;
475485

476486
return {
477487
onMove(event) {
478488
setSize(startSize + direction * (event[clientXorY] - startPos));
489+
if (!isResizing) {
490+
isResizing = true;
491+
onResizingChange$()(true);
492+
}
479493
},
480494
onEnd() {
481495
drawerElement.style[isVertical ? 'height' : 'width'] = '';
482-
onResizingChange$()(false);
496+
if (isResizing) {
497+
onResizingChange$()(false);
498+
isResizing = false;
499+
}
483500
},
484501
};
485502
}),

0 commit comments

Comments
 (0)