all files / component/tiles/ tile-position.directive.ts

100% Statements 20/20
100% Branches 2/2
100% Functions 3/3
100% Lines 15/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                              38× 38×       66× 18× 18× 18× 18× 18× 18×   48×        
/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
 
import { Directive, ElementRef, Input } from '@angular/core';
import { Rect } from '../../common/core/graphics/rect';
 
@Directive({
    selector: '[deja-tile-position]',
})
export class DejaTilePositionDirective {
    private element: HTMLElement;
 
    constructor(el: ElementRef) {
        this.element = el.nativeElement as HTMLElement;
        this.element.style.display = 'none';
    }
 
    @Input()
    public set bounds(rect: Rect) {
        if (rect) {
            const {left, top, width, height } = rect;
            this.element.style.left = `${left}px`;
            this.element.style.top = `${top}px`;
            this.element.style.width = `${width}px`;
            this.element.style.height = `${height}px`;
            this.element.style.display = 'block';
        } else {
            this.element.style.display = 'none';
        }
    }
}