mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-19 09:22:12 +00:00
avoid selecting on resize
This commit is contained in:
1 parent
d52b61f707
commit
11709316d2
1 file changed
+16
@@ -12,6 +12,19 @@
|
|||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
function handleMouseDown(event: PointerEvent) {
|
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 startX = event.clientX;
|
||||||
const startY = event.clientY;
|
const startY = event.clientY;
|
||||||
const startAfter = after;
|
const startAfter = after;
|
||||||
@@ -32,10 +45,13 @@
|
|||||||
const handleMouseUp = () => {
|
const handleMouseUp = () => {
|
||||||
window.removeEventListener('pointermove', handleMouseMove);
|
window.removeEventListener('pointermove', handleMouseMove);
|
||||||
window.removeEventListener('pointerup', handleMouseUp);
|
window.removeEventListener('pointerup', handleMouseUp);
|
||||||
|
window.removeEventListener('pointercancel', handleMouseUp);
|
||||||
|
Object.assign(style, previous);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('pointermove', handleMouseMove);
|
window.addEventListener('pointermove', handleMouseMove);
|
||||||
window.addEventListener('pointerup', handleMouseUp);
|
window.addEventListener('pointerup', handleMouseUp);
|
||||||
|
window.addEventListener('pointercancel', handleMouseUp);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user