question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Snap to grid

See original GitHub issue

I would like to be able to drag and resize my elements while snapping to a grid

chrome-capture

This is my workaround:

  const getGrid = (grid: number) => {
    const items = [0];

    while(items[items.length - 1] < width) {
      items.push(items[items.length - 1] + grid)
    }

    return items;
  }
  
<Moveable
  verticalGuidelines={getGrid(8)}
  horizontalGuidelines={getGrid(8)}
/>

This solution is not good for big layouts.

We can do something like X % gridWidth === 0 and Y % gridHeight === 0 to check the grid lines instead of checking thousands of items in an array.

It could look like this

<Moveable
  snapToGrid={true}
  gridWidth={8}
  gridHeight={8}
/>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rememberlennycommented, Jun 25, 2021

This is a great feature. Thank you!

1reaction
daybrushcommented, Jun 17, 2021

Thank you for PR.

react-moveable 0.28.3 is released.

Check it again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request:Adding a snap to the grid - BOOX Help Center
Often it is drawn in different places of the note or other notes, and then it needs to be combined into one diagram,...
Read more >
Feature request: Pen tool snap to grid and guides
When drawing illustrations, logos and icons with the Pen tool, it's important to be able to precisely place and edit vector points and ......
Read more >
Snap to grid | Feature Requests - ProtoPie - Canny
Log in / Sign up. Roadmap · Feature Requests. 737. Voters. P. Powered by Canny. 3. Snap to grid. San Fran. Let us...
Read more >
Add a "Snap to" Grid to the Workspaces - Feature Requests ...
I see that you talked about a snap to grid for the workspaces back in April so I would like to make it...
Read more >
Snap to grid | Rebelle Ideas & Feature Requests | Forum | ..
I do like the ruler tool. but it would be nice to have snap to grid. and be able to set grid to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found