image-layout
image-layout copied to clipboard
Calculating height of row in fixed-partition mode with spacing enabled
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?
I see the same issues, larger gutters put the images out of aspect ratio