Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public equalBoxesHeights(): void {
- const productsBoxes: HTMLCollectionOf<Element> = document.getElementsByClassName('my-product-box');
- [].forEach.call(
- productsBoxes,
- (node: HTMLElement) => {
- const box: HTMLElement = <HTMLElement> (node.querySelector('.gfi-box'));
- if (box.style.height) {
- box.style.height = '';
- }
- },
- );
- const maxHeight: number = [].reduce.call(
- productsBoxes,
- (carry: number, node: HTMLElement) => {
- const height: number = Math.max(
- parseInt(window.getComputedStyle(node).getPropertyValue('height'), 10),
- node.offsetHeight,
- node.clientHeight,
- carry,
- );
- return height;
- },
- 0,
- );
- [].forEach.call(
- productsBoxes,
- (node: HTMLElement) => {
- const box: HTMLElement = <HTMLElement> (node.querySelector('.gfi-box'));
- node.style.overflow = 'hidden';
- box.style.minHeight = '0';
- box.style.height = `${maxHeight + 35}px`;
- },
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement