Svelte JS action for resizing HTML table columns
Based on jquery-resizable-columns
<script>
import { ResizableColumns } from 'svelte-resizable-columns';
</script>
<style>
table {
width: 600px;
border-collapse: collapse;
}
</style>
<table use:ResizableColumns>
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
...
</tbody>
</table>
<script>
const update = (e) => {
let event = e.type;
let leftWidth = e.detail.leftWidth;
let rightWidth = e.detail.rightWidth;
let leftColumn = e.detail.leftColumn;
let rightColumn = e.detail.rightColumn;
}
</script>
<table use:ResizableColumns on:resize-columns-start={update} on:resize-columns-move={update} on:resize-columns-stop={update}>
...
</table>