fix(database): column resize uses direct coordinate calculation
Replace delta-based approach with direct mouse-position-to-column-edge calculation: newW = ev.clientX - thLeft. No setPointerCapture needed, no coordinate drift.
This commit is contained in:
@@ -165,15 +165,13 @@
|
|||||||
handle.onpointerdown = function(e) {
|
handle.onpointerdown = function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.setPointerCapture(e.pointerId);
|
|
||||||
const propId = parseInt(this.dataset.propId);
|
const propId = parseInt(this.dataset.propId);
|
||||||
const th = this.parentElement;
|
const th = this.parentElement;
|
||||||
const startX = e.clientX;
|
const thLeft = th.getBoundingClientRect().left;
|
||||||
const startW = th.getBoundingClientRect().width;
|
|
||||||
|
|
||||||
function onMove(ev) {
|
function onMove(ev) {
|
||||||
const diff = ev.clientX - startX;
|
// Calculate width directly from mouse position relative to th left edge
|
||||||
const newW = Math.max(60, startW + diff);
|
const newW = Math.max(60, ev.clientX - thLeft);
|
||||||
state.colWidths[propId] = newW;
|
state.colWidths[propId] = newW;
|
||||||
th.style.width = newW + 'px';
|
th.style.width = newW + 'px';
|
||||||
th.style.minWidth = newW + 'px';
|
th.style.minWidth = newW + 'px';
|
||||||
@@ -185,8 +183,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onUp(ev) {
|
function onUp() {
|
||||||
handle.releasePointerCapture(ev.pointerId);
|
|
||||||
document.removeEventListener('pointermove', onMove);
|
document.removeEventListener('pointermove', onMove);
|
||||||
document.removeEventListener('pointerup', onUp);
|
document.removeEventListener('pointerup', onUp);
|
||||||
document.body.style.cursor = '';
|
document.body.style.cursor = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user