demo:optimize demo code

This commit is contained in:
pengfei.zhou
2020-01-06 10:43:18 +08:00
committed by osborn
parent 3b82935b24
commit 05b5c69080
25 changed files with 1860 additions and 1656 deletions

View File

@@ -1453,9 +1453,14 @@ function slideItem(item, config) {
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function scroller(content) {
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.content = content;
});
}

View File

@@ -2901,9 +2901,14 @@ function slideItem(item, config) {
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function scroller(content) {
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.content = content;
});
}

10
doric-js/index.d.ts vendored
View File

@@ -486,6 +486,9 @@ declare module 'doric/lib/src/widget/list' {
renderItem: (index: number) => ListItem;
itemCount: number;
batchCount?: number;
onLoadMore?: () => void;
loadMore?: boolean;
loadMoreView?: ListItem;
}
export class List extends Superview implements IList {
allSubviews(): IterableIterator<ListItem> | ListItem[];
@@ -538,9 +541,9 @@ declare module 'doric/lib/src/widget/slider' {
declare module 'doric/lib/src/widget/scroller' {
import { Superview, View, IView, NativeViewModel } from 'doric/lib/src/ui/view';
export function scroller(content: View): Scroller;
export function scroller(content: View, config?: IScroller): Scroller;
export interface IScroller extends IView {
content: View;
content?: View;
}
export class Scroller extends Superview implements IScroller {
content: View;
@@ -598,6 +601,9 @@ declare module 'doric/lib/src/widget/flowlayout' {
columnCount?: number;
columnSpace?: number;
rowSpace?: number;
loadMore?: boolean;
onLoadMore?: () => void;
loadMoreView?: FlowLayoutItem;
}
export class FlowLayout extends Superview implements IFlowLayout {
allSubviews(): IterableIterator<FlowLayoutItem> | FlowLayoutItem[];

View File

@@ -16,6 +16,9 @@ export interface IFlowLayout extends IView {
columnCount?: number;
columnSpace?: number;
rowSpace?: number;
loadMore?: boolean;
onLoadMore?: () => void;
loadMoreView?: FlowLayoutItem;
}
export declare class FlowLayout extends Superview implements IFlowLayout {
private cachedViews;

View File

@@ -13,6 +13,9 @@ export interface IList extends IView {
renderItem: (index: number) => ListItem;
itemCount: number;
batchCount?: number;
onLoadMore?: () => void;
loadMore?: boolean;
loadMoreView?: ListItem;
}
export declare class List extends Superview implements IList {
private cachedViews;

View File

@@ -1,7 +1,7 @@
import { Superview, View, IView, NativeViewModel } from '../ui/view';
export declare function scroller(content: View): Scroller;
export declare function scroller(content: View, config?: IScroller): Scroller;
export interface IScroller extends IView {
content: View;
content?: View;
}
export declare class Scroller extends Superview implements IScroller {
content: View;

View File

@@ -15,9 +15,14 @@
*/
import { Superview } from '../ui/view';
import { layoutConfig } from '../util/layoutconfig';
export function scroller(content) {
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.content = content;
});
}

View File

@@ -6,10 +6,10 @@
"types": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc -d -p .&& rollup -c",
"build": "tsc -d -p .&& rollup -c && dts-bundle --configJson dts-bundle.json",
"dev": "tsc -w -p . & rollup -c -w",
"clean": "rm -rf build && rm -rf bundle",
"prepublish": "npm run build && dts-bundle --configJson dts-bundle.json"
"prepublish": "npm run build"
},
"repository": {
"type": "https",
@@ -31,4 +31,4 @@
"typescript": "^3.7.4",
"ws": "^7.2.1"
}
}
}

View File

@@ -42,6 +42,12 @@ export interface IFlowLayout extends IView {
columnSpace?: number
rowSpace?: number
loadMore?: boolean
onLoadMore?: () => void
loadMoreView?: FlowLayoutItem
}
export class FlowLayout extends Superview implements IFlowLayout {

View File

@@ -34,6 +34,9 @@ export interface IList extends IView {
renderItem: (index: number) => ListItem
itemCount: number
batchCount?: number
onLoadMore?: () => void
loadMore?: boolean
loadMoreView?: ListItem
}
export class List extends Superview implements IList {

View File

@@ -16,15 +16,20 @@
import { Superview, View, IView, NativeViewModel } from '../ui/view'
import { layoutConfig } from '../util/layoutconfig'
export function scroller(content: View) {
export function scroller(content: View, config?: IScroller) {
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.content = content
})
}
export interface IScroller extends IView {
content: View
content?: View
}
export class Scroller extends Superview implements IScroller {