alssndro / sandros-sketch-plugins

An assortment of random sketch plugins
MIT License
795 stars 21 forks source link

Horizontal Alignment Plugins bug #5

Open alssndro opened 10 years ago

alssndro commented 10 years ago

This bug concerns converting a Layout Grid to Ruler guides

It occurs with grids with non-whole-number column/gutter widths. Note that the Sketch UI will display columns/grids as being whole numbers, when in fact they are not, and are stored as a double.

See example below. A 1000px grid, 12 columns, gutters on outside, gutter width 33px, column width 50px.

image

Notice how the gutters widths are inconsistent. This is what throws off the plugin, since when the plugin recreates the grid internally, it uses the same column and gutter width for every column/gutter (since that's all the API allows access to).

This bug could easily be fixed if the Sketch API allowed access to each column in the MSLayoutGrid, rather than simply the gutter/column width values. Or if there is a way to predict the exact columns widths Sketch uses on grids with non-whole-number gutter/column widths.

Because the plugin's internal model of the grid is slightly off sometimes, it affects all Horizontal Alignment plugins. The actual logic for aligning/resizing elements amongst columns is (seemingly) correct, it's just that the slight disparity (often 1-2px at most) between the plugins model of the grid and the actual Sketch grid leads to things not working perfectly.

ghost commented 10 years ago

This plugin has never worked for me, ever. Am I installing it wrong?

alssndro commented 10 years ago

Possibly, how did you install the plugins

The easiest way to tell is to try the other plugins, or for Grids specifically, use the 'Draw Grid as Guidelines' plugin.

  1. Create a new Document, then a new Artboard inside it.
  2. Make sure both Rulers and the Layout Grid are showing (View > Show Rulers, View > Show Layout)
  3. View > Edit Layout and make sure the width of the Layout Grid matches the width of your Artboard.
  4. Activate the Grid > Draw Grid As Guidelines plugin. If everything is installed correctly, you should see ruler guides drawn over your Artboard and Layout Grid.

Also remember that if you have multiple Artboards in your document, Rulers/Layout will only show on the currently active one.