Files
NativeScript/tns-core-modules/ui/layouts/wrap-layout/wrap-layout-common.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

30 lines
1.5 KiB
TypeScript

import { WrapLayout as WrapLayoutDefinition, Orientation } from ".";
import { LayoutBase, Property, isIOS, Length, makeValidator, makeParser } from "../layout-base";
export * from "../layout-base";
export class WrapLayoutBase extends LayoutBase implements WrapLayoutDefinition {
public orientation: Orientation;
public itemWidth: Length;
public itemHeight: Length;
public effectiveItemWidth: number;
public effectiveItemHeight: number;
}
WrapLayoutBase.prototype.recycleNativeView = "auto";
export const itemWidthProperty = new Property<WrapLayoutBase, Length>({
name: "itemWidth", defaultValue: "auto", affectsLayout: isIOS, valueConverter: (v) => Length.parse(v),
valueChanged: (target, oldValue, newValue) => target.effectiveItemWidth = Length.toDevicePixels(newValue, -1)
});
itemWidthProperty.register(WrapLayoutBase);
export const itemHeightProperty = new Property<WrapLayoutBase, Length>({
name: "itemHeight", defaultValue: "auto", affectsLayout: isIOS, valueConverter: (v) => Length.parse(v),
valueChanged: (target, oldValue, newValue) => target.effectiveItemHeight = Length.toDevicePixels(newValue, -1)
});
itemHeightProperty.register(WrapLayoutBase);
const converter = makeParser<Orientation>(makeValidator<Orientation>("horizontal", "vertical"));
export const orientationProperty = new Property<WrapLayoutBase, Orientation>({ name: "orientation", defaultValue: "horizontal", affectsLayout: isIOS, valueConverter: converter });
orientationProperty.register(WrapLayoutBase);