optimize js code

This commit is contained in:
pengfei.zhou
2021-08-31 12:49:47 +08:00
committed by osborn
parent 612e5a4a07
commit 1b10106eb3
31 changed files with 109 additions and 271 deletions

View File

@@ -131,6 +131,7 @@ export declare abstract class View implements Modeling {
* Only affected when its superview or itself is FlexLayout.
*/
flexConfig?: FlexConfig;
set props(props: Partial<this>);
doAnimation(context: BridgeContext, animation: IAnimation): Promise<void>;
clearAnimation(context: BridgeContext, animation: IAnimation): Promise<void>;
cancelAnimation(context: BridgeContext, animation: IAnimation): Promise<void>;

View File

@@ -200,6 +200,9 @@ export class View {
getLocationOnScreen(context) {
return this.nativeChannel(context, "getLocationOnScreen")();
}
set props(props) {
this.apply(props);
}
doAnimation(context, animation) {
return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => {
for (let key in args) {

View File

@@ -43,9 +43,7 @@ export function draggable(views, config) {
});
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
}
return ret;
}

View File

@@ -141,9 +141,7 @@ export function flowItem(item, config) {
});
}
if (config) {
for (let key in config) {
Reflect.set(it, key, Reflect.get(config, key, config), it);
}
it.apply(config);
}
});
}

View File

@@ -105,8 +105,6 @@ __decorate([
export function image(config) {
const ret = new Image;
ret.layoutConfig = layoutConfig().fit();
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
return ret;
}

View File

@@ -146,8 +146,6 @@ export var InputType;
export function input(config) {
const ret = new Input;
ret.layoutConfig = layoutConfig().just();
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
return ret;
}

View File

@@ -50,9 +50,7 @@ export function stack(views, config) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
}
return ret;
}
@@ -63,9 +61,7 @@ export function hlayout(views, config) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
}
return ret;
}
@@ -76,9 +72,7 @@ export function vlayout(views, config) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
}
return ret;
}
@@ -91,9 +85,7 @@ export function flexlayout(views, config) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
}
return ret;
}

View File

@@ -123,9 +123,7 @@ __decorate([
], List.prototype, "bounces", void 0);
export function list(config) {
const ret = new List;
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
return ret;
}
export function listItem(item, config) {
@@ -140,9 +138,7 @@ export function listItem(item, config) {
});
}
if (config) {
for (let key in config) {
Reflect.set(it, key, Reflect.get(config, key, config), it);
}
it.apply(config);
}
});
}

View File

@@ -42,9 +42,7 @@ __decorate([
export function refreshable(config) {
const ret = new Refreshable;
ret.layoutConfig = layoutConfig().fit();
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
return ret;
}
export function pullable(v, config) {

View File

@@ -28,9 +28,7 @@ export function scroller(content, config) {
return (new Scroller).also(v => {
v.layoutConfig = layoutConfig().fit();
if (config) {
for (let key in config) {
Reflect.set(v, key, Reflect.get(config, key, config), v);
}
v.apply(config);
}
v.content = content;
});

View File

@@ -90,9 +90,7 @@ __decorate([
], Slider.prototype, "bounces", void 0);
export function slider(config) {
const ret = new Slider;
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
return ret;
}
export function slideItem(item, config) {

View File

@@ -52,8 +52,6 @@ export function switchView(config) {
ret.layoutConfig = layoutConfig().just();
ret.width = 50;
ret.height = 30;
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
return ret;
}

View File

@@ -93,8 +93,6 @@ __decorate([
export function text(config) {
const ret = new Text;
ret.layoutConfig = layoutConfig().fit();
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
ret.apply(config);
return ret;
}