Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

35 lines
742 B

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Sebastian Stehle. All rights reserved
*/
import { Directive, ElementRef, HostListener, OnInit, Renderer } from '@angular/core';
@Directive({
selector: '[sqxSquare]'
})
export class SquareDirective implements OnInit {
constructor(
private readonly element: ElementRef,
private readonly renderer: Renderer
) {
}
public ngOnInit() {
this.resize();
}
@HostListener('resize')
public onResize() {
this.resize();
}
private resize() {
const size = this.element.nativeElement.getBoundingClientRect();
this.renderer.setElementStyle(this.element.nativeElement, 'height', size.width + 'px');
}
}