UNPKG

uicore-ts

Version:

UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework tha

133 lines (48 loc) 2.14 kB
import { NO, YES } from "./UIObject" import { UIView } from "./UIView" export class UIActionIndicator extends UIView { indicatorView: UIView _size: number = 50 constructor(elementID?: string) { super(elementID) this.indicatorView = new UIView(this.elementID + "IndicatorView") this.indicatorView.viewHTMLElement.classList.add("LukeHaasLoader") this.addSubview(this.indicatorView) this.hidden = YES } set size(size: number) { this._size = size this.setNeedsLayoutUpToRootView() } get size() { return this._size } override set hidden(hidden: boolean) { super.hidden = hidden if (hidden) { this.indicatorView.removeFromSuperview() } else { this.addSubview(this.indicatorView) } } start() { this.hidden = NO } stop() { this.hidden = YES } override layoutSubviews() { super.layoutSubviews() const bounds = this.bounds //this.indicatorView.centerInContainer(); this.indicatorView.style.height = "" + this._size.integerValue + "px" this.indicatorView.style.width = "" + this._size.integerValue + "px" const minSize = Math.min(this.bounds.height, this.bounds.width) this.indicatorView.style.maxHeight = "" + minSize.integerValue + "px" this.indicatorView.style.maxWidth = "" + minSize.integerValue + "px" const size = Math.min(this._size, minSize) this.indicatorView.style.left = "" + ((bounds.width - size) * 0.5 - 11).integerValue + "px" this.indicatorView.style.top = "" + ((bounds.height - size) * 0.5 - 11).integerValue + "px" } }