You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Problem:**
The orange grid gap controls are sometimes 1px off, they are one frame
behind, they show weird delays when the canvas zooms.
**Fix:**
A lot of the problem came down to `gridGapControlBoundsFromMetadata`
trying to calculate the bounding boxes of where the gaps are in the
selected Grid. However this is error prone because a lot of these boxes
will fall on fractional pixel values, and we were not rounding them the
same way Chrome was rounding the real grid.
Instead of trying to fix the math, I had an idea to replicate our hack
for the grid cell outline controls: take the
ComputedStyle.gridTemplateRows / Columns, and create a helper grid which
has the correct position and sizing for our gap outlines. The trick is
that we want to take the original grid's gap value, and turn those into
grid tracks too, setting the helper grid's gap to zero.
So if my original grid's ComputedStyle has tracks [5px 10px 15px 5px]
and a gap of 13px, we would create a helper grid with the tracks [5px
13px 10px 13px 15px 13px 5px]!
Now the only job is to fill it with the elements and make sure to only
draw anything in the tracks that correspond to gaps in the original grid
(they are always the odd numbered tracks).
This means we can offload the entire positioning and rendering to
Chrome, and makes our life much simpler going forward.
**Commit Details:**
- Fixed Hot Reload by creating a new file
`grid-gap-control-component.tsx`
- Brand new `GridGapControlComponent`, `GridPaddingOutlineForDimension`
and `GridRowHighlight` components.
- `GridPaddingOutlineForDimension` creates the helper grid with the
inlined gaps as tracks
- `GridRowHighlight` is responsible for the visual lines, and it
recreates the original grid in the given dimension so it can have a
handle for each original row
- `GridGapHandle` mostly unchanged
---------
Co-authored-by: Federico Ruggi <1081051+ruggi@users.noreply.github.com>
0 commit comments