optimize: clean view's props after being bunched fetched from native
This commit is contained in:
49
doric-web/dist/index.js
vendored
49
doric-web/dist/index.js
vendored
@@ -3464,6 +3464,19 @@ function image(config) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function deepClone(nativeViewModel) {
|
||||
const ret = {
|
||||
id: nativeViewModel.id,
|
||||
type: nativeViewModel.type,
|
||||
props: Object.assign({}, nativeViewModel.props),
|
||||
};
|
||||
if (nativeViewModel.props.subviews) {
|
||||
ret.props.subviews = nativeViewModel.props.subviews
|
||||
.map(e => deepClone(e));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright [2019] [Doric.Pub]
|
||||
*
|
||||
@@ -3549,10 +3562,11 @@ class List extends Superview {
|
||||
return view;
|
||||
}
|
||||
renderBunchedItems(start, length) {
|
||||
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
|
||||
const listItem = this.getItem(start + idx);
|
||||
return listItem.toModel();
|
||||
});
|
||||
const items = new Array(Math.max(0, Math.min(length, this.itemCount - start)))
|
||||
.fill(0).map((_, idx) => this.getItem(start + idx));
|
||||
const ret = items.map(e => deepClone(e.toModel()));
|
||||
items.forEach(e => e.clean());
|
||||
return ret;
|
||||
}
|
||||
toModel() {
|
||||
if (this.loadMoreView) {
|
||||
@@ -3699,10 +3713,11 @@ class Slider extends Superview {
|
||||
return view;
|
||||
}
|
||||
renderBunchedItems(start, length) {
|
||||
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
|
||||
const slideItem = this.getItem(start + idx);
|
||||
return slideItem.toModel();
|
||||
});
|
||||
const items = new Array(Math.max(0, Math.min(length, this.itemCount - start)))
|
||||
.fill(0).map((_, idx) => this.getItem(start + idx));
|
||||
const ret = items.map(e => deepClone(e.toModel()));
|
||||
items.forEach(e => e.clean());
|
||||
return ret;
|
||||
}
|
||||
slidePage(context, page, smooth = false) {
|
||||
return this.nativeChannel(context, "slidePage")({ page, smooth });
|
||||
@@ -4094,10 +4109,11 @@ class FlowLayout extends Superview {
|
||||
return view;
|
||||
}
|
||||
renderBunchedItems(start, length) {
|
||||
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
|
||||
const listItem = this.getItem(start + idx);
|
||||
return listItem.toModel();
|
||||
});
|
||||
const items = new Array(Math.max(0, Math.min(length, this.itemCount - start)))
|
||||
.fill(0).map((_, idx) => this.getItem(start + idx));
|
||||
const ret = items.map(e => deepClone(e.toModel()));
|
||||
items.forEach(e => e.clean());
|
||||
return ret;
|
||||
}
|
||||
toModel() {
|
||||
if (this.loadMoreView) {
|
||||
@@ -4684,10 +4700,11 @@ class HorizontalList extends Superview {
|
||||
return view;
|
||||
}
|
||||
renderBunchedItems(start, length) {
|
||||
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
|
||||
const listItem = this.getItem(start + idx);
|
||||
return listItem.toModel();
|
||||
});
|
||||
const items = new Array(Math.max(0, Math.min(length, this.itemCount - start)))
|
||||
.fill(0).map((_, idx) => this.getItem(start + idx));
|
||||
const ret = items.map(e => deepClone(e.toModel()));
|
||||
items.forEach(e => e.clean());
|
||||
return ret;
|
||||
}
|
||||
toModel() {
|
||||
if (this.loadMoreView) {
|
||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user