Skip to content

Commit

Permalink
feat: onResizeEnd config handler
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanmylee committed Dec 22, 2022
1 parent b55c86c commit 0be6671
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/plugins/addResizedColumns.ts
Expand Up @@ -4,6 +4,10 @@ import { sum } from '../utils/math';
import { keyed } from 'svelte-keyed';
import { derived, writable, type Writable } from 'svelte/store';

export interface AddResizedColumnsConfig {
onResizeEnd?: (ev: Event) => void;
}

export type ResizedColumnsState = {
columnWidths: Writable<Record<string, number>>;
};
Expand Down Expand Up @@ -63,7 +67,9 @@ type ColumnsWidthState = {
};

export const addResizedColumns =
<Item>(): TablePlugin<
<Item>({
onResizeEnd,
}: AddResizedColumnsConfig): TablePlugin<
Item,
ResizedColumnsState,
ResizedColumnsColumnOptions,
Expand Down Expand Up @@ -181,6 +187,7 @@ export const addResizedColumns =
}));
}
}
onResizeEnd?.(event);
if (event instanceof MouseEvent) {
window.removeEventListener('mousemove', dragMove);
window.removeEventListener('mouseup', dragEnd);
Expand Down

1 comment on commit 0be6671

@vercel
Copy link

@vercel vercel bot commented on 0be6671 Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.