Files
NativeScript/tns-core-modules/ui/border/border.ts
Hristo Hristov 0f14101238 recycling now happens only if nativeView and android properties are not accessed. (#4627)
recycleNativeView filed now accepts: "always" | "never" | "auto". Always will recycle the nativeView no matter if its nativeView or android proprties are accessed. Never will disable recycling. Auto will recycle it only if nativeView and android properties are not accessed.
2017-08-01 15:04:16 +03:00

44 lines
2.0 KiB
TypeScript

import { Border as BorderDefinition } from ".";
import { ContentView, View, layout } from "../content-view";
@Deprecated
export class Border extends ContentView implements BorderDefinition {
get cornerRadius(): number {
if (typeof this.borderRadius === "number") {
return <number>this.borderRadius;
}
return 0;
}
set cornerRadius(value: number) {
this.borderRadius = value;
}
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
const width = layout.getMeasureSpecSize(widthMeasureSpec);
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
const height = layout.getMeasureSpecSize(heightMeasureSpec);
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
const horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
const verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
const result = View.measureChild(this, this.layoutView,
layout.makeMeasureSpec(width - horizontalBorderLength, widthMode),
layout.makeMeasureSpec(height - verticalBorderLength, heightMode));
const widthAndState = View.resolveSizeAndState(result.measuredWidth + horizontalBorderLength, width, widthMode, 0);
const heightAndState = View.resolveSizeAndState(result.measuredHeight + verticalBorderLength, height, heightMode, 0);
this.setMeasuredDimension(widthAndState, heightAndState);
}
public onLayout(left: number, top: number, right: number, bottom: number): void {
let horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
let verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
View.layoutChild(this, this.layoutView, this.effectiveBorderLeftWidth, this.effectiveBorderTopWidth, right - left - horizontalBorderLength, bottom - top - verticalBorderLength);
}
}
Border.prototype.recycleNativeView = "auto";