mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-19 02:49:56 +00:00
19 lines
718 B
TypeScript
19 lines
718 B
TypeScript
import { HostBinding, ElementRef } from '@angular/core'
|
|
import { BaseComponent } from './base.component'
|
|
|
|
export abstract class SelfPositioningComponent extends BaseComponent {
|
|
@HostBinding('style.left') cssLeft: string
|
|
@HostBinding('style.top') cssTop: string
|
|
@HostBinding('style.width') cssWidth: string | null
|
|
@HostBinding('style.height') cssHeight: string | null
|
|
|
|
constructor (protected element: ElementRef) { super() }
|
|
|
|
protected setDimensions (x: number, y: number, w: number, h: number, unit = '%'): void {
|
|
this.cssLeft = `${x}${unit}`
|
|
this.cssTop = `${y}${unit}`
|
|
this.cssWidth = w ? `${w}${unit}` : null
|
|
this.cssHeight = h ? `${h}${unit}` : null
|
|
}
|
|
}
|