mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
Merge pull request #1430 from NativeScript/gatanasov/lazy-require-fixes
Revisit lazy require routine
This commit is contained in:
@ -6,6 +6,13 @@ import color = require("color");
|
||||
import bindable = require("ui/core/bindable");
|
||||
import * as typesModule from "utils/types";
|
||||
|
||||
var types: typeof typesModule;
|
||||
function ensureTypes() {
|
||||
if (!types) {
|
||||
types = require("utils/types");
|
||||
}
|
||||
}
|
||||
|
||||
export module knownCollections {
|
||||
export var items = "items";
|
||||
}
|
||||
@ -40,7 +47,7 @@ export class SegmentedBar extends view.View implements definition.SegmentedBar {
|
||||
public _adjustSelectedIndex(items: Array<definition.SegmentedBarItem>) {
|
||||
if (this.items) {
|
||||
if (this.items.length > 0) {
|
||||
var types: typeof typesModule = require("utils/types");
|
||||
ensureTypes();
|
||||
|
||||
if (types.isUndefined(this.selectedIndex) || (this.selectedIndex > this.items.length - 1)) {
|
||||
this._setValue(SegmentedBar.selectedIndexProperty, 0);
|
||||
|
@ -11,6 +11,13 @@ import view = require("ui/core/view");
|
||||
|
||||
global.moduleMerge(common, exports);
|
||||
|
||||
var color: typeof colorModule;
|
||||
function ensureColor() {
|
||||
if (!color) {
|
||||
color = require("color");
|
||||
}
|
||||
}
|
||||
|
||||
function onSelectedIndexPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
var view = <SegmentedBar>data.object;
|
||||
if (!view.ios || !view.items) {
|
||||
@ -67,7 +74,7 @@ function onSelectedBackgroundColorPropertyChanged(data: dependencyObservable.Pro
|
||||
return;
|
||||
}
|
||||
|
||||
var color: typeof colorModule = require("color");
|
||||
ensureColor();
|
||||
|
||||
if (data.newValue instanceof color.Color) {
|
||||
view.ios.tintColor = data.newValue.ios;
|
||||
|
Reference in New Issue
Block a user