image-layout icon indicating copy to clipboard operation
image-layout copied to clipboard

Calculating height of row in fixed-partition mode with spacing enabled

Open thijsw opened this issue 8 years ago • 1 comments

With the following set up, the algorithm yield the results display below:

import layout from 'image-layout/layouts/fixed-partition'

const elements = [
  {"width":800,"height":536},
  {"width":708,"height":800},
  {"width":800,"height":536}
]

const result = layout(elements, {
  containerWidth: 1200,
  idealElementHeight: 280,
  spacing: 40
})
{
  "width": 1200,
  "height": 310,
  "positions": [
    {
      "y": 0,
      "x": 0,
      "width": 432,
      "height": 310
    },
    {
      "y": 0,
      "x": 472,
      "width": 256,
      "height": 310
    },
    {
      "y": 0,
      "x": 768,
      "width": 432,
      "height": 310
    }
  ]
}

Given the aspect ratio of the images, I'd expect the row to have a height of 290px instead of 310px. When spacing is set to 0 I get results that respect the aspect ratio. Do I miss something?

thijsw avatar Jun 28 '16 08:06 thijsw

I see the same issues, larger gutters put the images out of aspect ratio

johanneseckert avatar Jun 21 '19 21:06 johanneseckert