Skip to content

Instantly share code, notes, and snippets.

@PavelGonzales
Last active April 28, 2018 14:10
Show Gist options
  • Save PavelGonzales/b5891fbeeca4e2f517eaa79fc57936ad to your computer and use it in GitHub Desktop.
Save PavelGonzales/b5891fbeeca4e2f517eaa79fc57936ad to your computer and use it in GitHub Desktop.
/**
* Метод принимает
* @param {array} row // массив картинок в ряду.
* @param {HTMLElement} wrap // родитель картинок, наш компонент или блок.
**/
function flow(row, wrap) {
let aspect = 0;
const horizontalPadding = 5;
const maxHeight = 500;
// Собираем все картинки высчитываем соотношение сторон.
const imagesArray = row.map(image => {
const imageWidth = image.naturalWidth;
const imageHeight = image.naturalHeight;
const imageAspect = imageWidth / imageHeight || 1;
aspect = aspect + imageAspect;
return {image, aspect: imageAspect};
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment