Replies: 1 comment
|
You can access During an active resize, the projected column width is <script setup>
function getClampedDeltaOffset(header) {
const column = header.column;
const currentSize = column.getSize();
const minSize = column.columnDef.minSize ?? 20;
const maxSize = column.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER;
const rawDelta = header.getContext().table.getState().columnSizingInfo.deltaOffset ?? 0;
// The delta cannot reduce the size below minSize or expand it above maxSize
const minDelta = minSize - currentSize;
const maxDelta = maxSize - currentSize;
return Math.min(Math.max(rawDelta, minDelta), maxDelta);
}
</script>
<template>
<div
@dblclick="() => header.column.resetSize()"
@mousedown="(e) => header.getResizeHandler()(e)"
@touchstart="(e) => header.getResizeHandler()(e)"
:style="{
position: 'absolute',
right: 0,
top: 0,
bottom: 0,
zIndex: 10,
width: '6px',
height: '100%',
backgroundColor: 'red',
transform: header.column.getIsResizing()
? `translateX(${getClampedDeltaOffset(header)}px)`
: '',
}"
></div>
</template>Key points:
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Is there a way to prevent resizer from going beyond the column's size limit if I'm using onEnd? I tried to limit deltaOffset but I couldn't find a way to understand what kind of column size I would end up with after the resize is applied. My idea was to use something like min(deltaOffset, maxSize - currentSize), but I could not find an API to access column's max size, am I missing something?
That's what I'm talking about, I'm trying to prevent resizer from being moved too far from max size
All reactions