Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing with percentage width causes handle to drift from mouse position #846

Open
jinxiangqiang opened this issue Dec 24, 2024 · 0 comments

Comments

@jinxiangqiang
Copy link

jinxiangqiang commented Dec 24, 2024

Bug: Resizing with percentage width causes handle to drift from mouse position

Description

When using percentage width (e.g. width: "50%"), dragging the resize handle causes it to drift away from the mouse cursor. The drift gets worse with each resize operation, making it difficult to achieve precise sizing.

Steps to reproduce

  1. Create a resizable component with percentage width:
<th>
 <Resizable
  size={{ width: "100%", height: "100%" }}
  minWidth={80}
  style={{ position: 'absolute' }}
  >
</th>
  1. Try to resize the component by dragging the handle
  2. Observe that:
  • The handle position doesn't match the mouse cursor position
  • The drift gets worse with each resize operation
  • The final width after resizing may be incorrect

Expected behavior

  • The resize handle should stay aligned with the mouse cursor during resize
  • The final width should accurately reflect the mouse movement
  • Percentage widths should be handled correctly, converting to pixels for resize operations

Actual behavior

  • The resize handle drifts away from the mouse cursor
  • The drift accumulates with each resize operation
  • The final width may be incorrect due to percentage-to-pixel conversion issues

Environment

  • re-resizable version: 6.10.3
  • React version: 18.2.0
  • Browser: Chrome 120.0.6099.216

Additional context

This appears to be related to how the component handles percentage-to-pixel conversion during resize operations. The component might need to:

  1. Convert percentage to actual pixels before starting resize
  2. Handle the resize operation in pixels
  3. Convert back to percentage if needed after resize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant