avoid selecting on resize

This commit is contained in:
vcoppe committed 2026-10-17 20:02:09 +02:00
1 parent d52b61f707
commit 11709316d2
1 file changed
+16
+16
View File
@@ -12,6 +12,19 @@
} = $props();
function handleMouseDown(event: PointerEvent) {
// the text on either side is not selected while dragging, and the cursor stays the one of
// the resizer when the pointer leaves it
event.preventDefault();
const { style } = document.body;
const previous = {
userSelect: style.userSelect,
webkitUserSelect: style.webkitUserSelect,
cursor: style.cursor,
};
style.userSelect = 'none';
style.webkitUserSelect = 'none';
style.cursor = orientation === 'col' ? 'col-resize' : 'row-resize';
const startX = event.clientX;
const startY = event.clientY;
const startAfter = after;
@@ -32,10 +45,13 @@
const handleMouseUp = () => {
window.removeEventListener('pointermove', handleMouseMove);
window.removeEventListener('pointerup', handleMouseUp);
window.removeEventListener('pointercancel', handleMouseUp);
Object.assign(style, previous);
};
window.addEventListener('pointermove', handleMouseMove);
window.addEventListener('pointerup', handleMouseUp);
window.addEventListener('pointercancel', handleMouseUp);
}
</script>