js: declare scroll to item with top offset api

This commit is contained in:
王劲鹏
2023-08-03 18:58:28 +08:00
committed by osborn
parent e3ca9ae5d4
commit c4eee8ad4a
11 changed files with 990 additions and 574 deletions

View File

@@ -21,6 +21,7 @@ export declare abstract class Panel {
private headviews;
private onRenderFinishedCallback;
private __rendering__;
private callingRenderFinishedCallback;
addHeadView(type: string, v: View): void;
allHeadViews(): IterableIterator<Map<string, View>>;
removeHeadView(type: string, v: View | string): void;

View File

@@ -40,6 +40,7 @@ export class Panel {
this.headviews = new Map;
this.onRenderFinishedCallback = [];
this.__rendering__ = false;
this.callingRenderFinishedCallback = false;
this.snapshotEnabled = false;
this.renderSnapshots = [];
}
@@ -221,12 +222,17 @@ export class Panel {
return diryData;
}
onRenderFinished() {
this.callingRenderFinishedCallback = false;
this.onRenderFinishedCallback.forEach(e => {
e();
});
this.onRenderFinishedCallback.length = 0;
this.callingRenderFinishedCallback = true;
}
addOnRenderFinishedCallback(cb) {
if (this.callingRenderFinishedCallback) {
loge("Do not call addOnRenderFinishedCallback recursively");
}
this.onRenderFinishedCallback.push(cb);
}
}

View File

@@ -54,8 +54,12 @@ export declare class List extends Superview {
onDragging?: (from: number, to: number) => void;
onDragged?: (from: number, to: number) => void;
preloadItemCount?: number;
/**
* @param {number} config.topOffset - 目标位置cell的顶部偏移量
*/
scrollToItem(context: BridgeContext, index: number, config?: {
animated?: boolean;
topOffset?: number;
}): Promise<any>;
/**
* @param context

View File

@@ -50,9 +50,13 @@ export class List extends Superview {
}
return ret;
}
/**
* @param {number} config.topOffset - 目标位置cell的顶部偏移量
*/
scrollToItem(context, index, config) {
const animated = config === null || config === void 0 ? void 0 : config.animated;
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
const topOffset = config === null || config === void 0 ? void 0 : config.topOffset;
return this.nativeChannel(context, 'scrollToItem')({ index, animated, topOffset });
}
/**
* @param context