feat:scroller add onScroll and onScrollEnd property

This commit is contained in:
pengfei.zhou
2020-03-03 15:51:20 +08:00
committed by osborn
parent 0fa121e54f
commit 021fdab35f
16 changed files with 141 additions and 3 deletions

View File

@@ -2029,6 +2029,14 @@ var Scroller = /** @class */ (function (_super) {
Property,
__metadata$7("design:type", Object)
], Scroller.prototype, "contentOffset", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Function)
], Scroller.prototype, "onScroll", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Function)
], Scroller.prototype, "onScrollEnd", void 0);
return Scroller;
}(Superview));
@@ -3040,6 +3048,9 @@ var ViewModel = /** @class */ (function () {
ViewModel.prototype.getState = function () {
return this.state;
};
ViewModel.prototype.getViewHolder = function () {
return this.viewHolder;
};
ViewModel.prototype.updateState = function (setter) {
setter(this.state);
this.onBind(this.state, this.viewHolder);

View File

@@ -1510,6 +1510,14 @@ __decorate$7([
Property,
__metadata$7("design:type", Object)
], Scroller.prototype, "contentOffset", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Function)
], Scroller.prototype, "onScroll", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Function)
], Scroller.prototype, "onScrollEnd", void 0);
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2258,6 +2266,9 @@ class ViewModel {
getState() {
return this.state;
}
getViewHolder() {
return this.viewHolder;
}
updateState(setter) {
setter(this.state);
this.onBind(this.state, this.viewHolder);

View File

@@ -2969,6 +2969,14 @@ __decorate$7([
Property,
__metadata$7("design:type", Object)
], Scroller.prototype, "contentOffset", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Function)
], Scroller.prototype, "onScroll", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Function)
], Scroller.prototype, "onScrollEnd", void 0);
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3717,6 +3725,9 @@ class ViewModel {
getState() {
return this.state;
}
getViewHolder() {
return this.viewHolder;
}
updateState(setter) {
setter(this.state);
this.onBind(this.state, this.viewHolder);

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

@@ -587,6 +587,14 @@ declare module 'doric/lib/src/widget/scroller' {
x: number;
y: number;
};
onScroll?: (offset: {
x: number;
y: number;
}) => void;
onScrollEnd?: (offset: {
x: number;
y: number;
}) => void;
allSubviews(): View[];
toModel(): NativeViewModel;
scrollTo(context: BridgeContext, offset: {
@@ -1139,6 +1147,7 @@ declare module 'doric/lib/src/pattern/mvvm' {
export abstract class ViewModel<M extends Object, V extends ViewHolder> {
constructor(obj: M, v: V);
getState(): M;
getViewHolder(): V;
updateState(setter: Setter<M>): void;
attach(view: Group): void;
abstract onAttached(state: M, vh: V): void;

View File

@@ -9,6 +9,7 @@ export declare abstract class ViewModel<M extends Object, V extends ViewHolder>
private viewHolder;
constructor(obj: M, v: V);
getState(): M;
getViewHolder(): V;
updateState(setter: Setter<M>): void;
attach(view: Group): void;
abstract onAttached(state: M, vh: V): void;

View File

@@ -9,6 +9,9 @@ export class ViewModel {
getState() {
return this.state;
}
getViewHolder() {
return this.viewHolder;
}
updateState(setter) {
setter(this.state);
this.onBind(this.state, this.viewHolder);

View File

@@ -14,6 +14,14 @@ export declare class Scroller extends Superview implements IScroller {
x: number;
y: number;
};
onScroll?: (offset: {
x: number;
y: number;
}) => void;
onScrollEnd?: (offset: {
x: number;
y: number;
}) => void;
allSubviews(): View[];
toModel(): NativeViewModel;
scrollTo(context: BridgeContext, offset: {

View File

@@ -54,3 +54,11 @@ __decorate([
Property,
__metadata("design:type", Object)
], Scroller.prototype, "contentOffset", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], Scroller.prototype, "onScroll", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], Scroller.prototype, "onScrollEnd", void 0);

View File

@@ -35,6 +35,10 @@ export abstract class ViewModel<M extends Object, V extends ViewHolder> {
return this.state
}
getViewHolder() {
return this.viewHolder;
}
updateState(setter: Setter<M>) {
setter(this.state)
this.onBind(this.state, this.viewHolder)

View File

@@ -40,6 +40,12 @@ export class Scroller extends Superview implements IScroller {
@Property
contentOffset?: { x: number, y: number }
@Property
onScroll?: (offset: { x: number, y: number }) => void
@Property
onScrollEnd?: (offset: { x: number, y: number }) => void
allSubviews() {
return [this.content]
}