Skip to content

Instantly share code, notes, and snippets.

View PavelGonzales's full-sized avatar
💜
Beauty Coder

Pavel Gonzales PavelGonzales

💜
Beauty Coder
View GitHub Profile
import { NotificationService } from '../../../services/notification/notification.service';
import { SalonsService } from '../../../services/salons/salons.service';
import { User, Salon, Notification } from '../../../../stub';
import { UserService } from '../../../services/user/user.service';
import { Component, OnInit, Output, EventEmitter, Input, ElementRef, NgZone } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { BookingService } from '../../../services/booking/booking.service';
import { Subscription } from 'rxjs/Subscription';
@Component({
/**
* Метод принимает
* @param {array} row // массив картинок в ряду.
* @param {HTMLElement} wrap // родитель картинок, наш компонент или блок.
**/
function flow(row, wrap) {
let aspect = 0;
const horizontalPadding = 5;
const maxHeight = 500;
/**
* Метод принимает
* @param {array} row // массив картинок в ряду.
* @param {HTMLElement} wrap // родитель картинок, наш компонент.
**/
function flow(row, wrap) {
const rowArray = Array.from(row);
let aspect = 0;
const horizontalPadding = 4;
const maxHeight = 500;
let aspect = 0; // сумма наших соотношений сторон у изображений
const horizontalPadding = 5; // отступ у изображений по горизонтали
const maxHeight = 500; // максимальная высота изображения, нужно если у нас одно изображение
const imageWidth = image.naturalWidth;
const imageHeight = image.naturalHeight;
const imageAspect = imageWidth / imageHeight || 1;
aspect = aspect + imageAspect;
// Высчитываем ширину ряда что-бы вычислить процентную ширину каждой картинки.
const rowWidth = wrap.offsetWidth;
// Высчитываем высоту ряда.
let rowHeight = rowWidth / aspect - horizontalPadding;
if ((rowHeight > maxHeight) && this.totalImages === 1) {
rowHeight = maxHeight;
}
imagesArray.forEach(image => {
image.image.style.width = `${(rowHeight * image.aspect) * 100 / rowWidth}%`;
});