Skip to content

Commit

Permalink
Set editor width to actual width at end of resize
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaines committed Nov 13, 2024
1 parent 73dc6a0 commit 3e6692b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/website/src/components/Resize.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ export default function Resize({ onResize }) {
function handleMouseDown(e) {
e.preventDefault();

const rect = e.target.getBoundingClientRect();
const resizeRect = resizeRef.current.getBoundingClientRect();

dragging = true;
dragOffset = Math.round(e.clientX - rect.left);
dragOffset = Math.round(e.clientX - resizeRect.left);
}

function handleMouseMove(e) {
if (dragging) {
let width = Math.max(0, e.clientX - dragOffset);
const width = Math.max(0, e.clientX - dragOffset);
onResize(width);
}
}

function handleMouseUp() {
if (dragging) {
const resizeRect = resizeRef.current.getBoundingClientRect();
onResize(resizeRect.left);
}

dragging = false;
}

Expand Down

0 comments on commit 3e6692b

Please sign in to comment.