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

The grid prop doesn't account for grid gaps #822

Closed
alexiz10 opened this issue Jun 24, 2024 · 0 comments · Fixed by #823
Closed

The grid prop doesn't account for grid gaps #822

alexiz10 opened this issue Jun 24, 2024 · 0 comments · Fixed by #823

Comments

@alexiz10
Copy link
Contributor

This can be considered both a bug and a feature request.

Overview of the problem

I'm using re-resizable version [6.9.17]

My browser is:
Firefox, Chrome, Safari

I am sure this issue is not a duplicate?

Description

Basically, I was given a design for a grid that will contains draggable/resizable items. The design for the grid contains these grid cells in the background to which the resizable/draggable item will snap to. Here is a screenshot from the Figma design:
Screenshot 2024-06-24 at 2 49 58 PM

As you can see from the screenshot, the items will span hSpan * (gridCellWidth + gridGap) - gridGap, So the width of the item will always be one gridGap less than the gridCellWidth amount. Now, since I still need the items to resize by gridCellWidth + gridGap to account for the gaps, I provided the grid prop with

grid={[gridCellWidth + gridGap, gridCellHeight + gridGap]}

this works fine, as it actually resizes by the correct amount. But, at the start of the resize action, since the width of the item doesn't include that last gap, it will immediately snap 3px horizontally and 3px vertically. Then, the grid calculations go from there, so it is always off by 3px. When the resizing ends, I can just adjust the actual size, but this causes a UI bug for the users that doesn't look great.

Steps to Reproduce

  1. Create a Resizable component
  2. Give it grid values that include a grid gap ([gridCellWidth + gridGap, gridCellHeight + gridGap])
  3. Set the initial width of the Resizable to something like 2 * (gridCellWidth + gridGap) - gridGap
  4. Try to resize and see how the resizable will jump to accommodate the extra gap and it will now resize based on that point.

https://playcode.io/1916463

Feature request

I think a good feature would be to add an optional prop that would allow you to pass in a grid gap. If this is set, then the resizable would handle the gap accordingly.

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

Successfully merging a pull request may close this issue.

1 participant