ng-ytl-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
58 lines (47 loc) • 1.5 kB
text/typescript
import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { toBoolean } from '../util/convert';
export class NzSliderTrackComponent implements OnChanges {
private _vertical = false;
private _included = false;
// Dynamic properties
nzOffset;
nzLength;
// Static properties
nzClassName;
set nzVertical(value: boolean) { // Required
this._vertical = toBoolean(value);
}
get nzVertical(): boolean {
return this._vertical;
}
set nzIncluded(value: boolean) {
this._included = toBoolean(value);
}
get nzIncluded(): boolean {
return this._included;
}
style: { bottom?: string, height?: string, left?: string, width?: string, visibility?: string } = {};
ngOnChanges(changes: SimpleChanges): void {
if (changes.nzIncluded) {
this.style.visibility = this.nzIncluded ? 'visible' : 'hidden';
}
if (changes.nzVertical || changes.nzOffset || changes.nzLength) {
if (this.nzVertical) {
this.style.bottom = `${this.nzOffset}%`;
this.style.height = `${this.nzLength}%`;
} else {
this.style.left = `${this.nzOffset}%`;
this.style.width = `${this.nzLength}%`;
}
}
}
}