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

@@ -1132,6 +1132,7 @@ var Panel = /** @class */ (function () {
this.headviews = new Map;
this.onRenderFinishedCallback = [];
this.__rendering__ = false;
this.callingRenderFinishedCallback = false;
this.snapshotEnabled = false;
this.renderSnapshots = [];
}
@@ -1370,12 +1371,17 @@ var Panel = /** @class */ (function () {
return diryData;
};
Panel.prototype.onRenderFinished = function () {
this.callingRenderFinishedCallback = false;
this.onRenderFinishedCallback.forEach(function (e) {
e();
});
this.onRenderFinishedCallback.length = 0;
this.callingRenderFinishedCallback = true;
};
Panel.prototype.addOnRenderFinishedCallback = function (cb) {
if (this.callingRenderFinishedCallback) {
loge("Do not call addOnRenderFinishedCallback recursively");
}
this.onRenderFinishedCallback.push(cb);
};
__decorate$e([
@@ -2558,9 +2564,13 @@ var List = /** @class */ (function (_super) {
}
return ret;
};
/**
* @param {number} config.topOffset - 目标位置cell的顶部偏移量
*/
List.prototype.scrollToItem = function (context, index, config) {
var animated = config === null || config === void 0 ? void 0 : config.animated;
return this.nativeChannel(context, 'scrollToItem')({ index: index, animated: animated, });
var topOffset = config === null || config === void 0 ? void 0 : config.topOffset;
return this.nativeChannel(context, 'scrollToItem')({ index: index, animated: animated, topOffset: topOffset });
};
/**
* @param context

View File

@@ -867,6 +867,7 @@ class Panel {
this.headviews = new Map;
this.onRenderFinishedCallback = [];
this.__rendering__ = false;
this.callingRenderFinishedCallback = false;
this.snapshotEnabled = false;
this.renderSnapshots = [];
}
@@ -1048,12 +1049,17 @@ 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);
}
}
@@ -1910,9 +1916,13 @@ 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

File diff suppressed because it is too large Load Diff

View File

@@ -2407,6 +2407,7 @@ class Panel {
this.headviews = new Map;
this.onRenderFinishedCallback = [];
this.__rendering__ = false;
this.callingRenderFinishedCallback = false;
this.snapshotEnabled = false;
this.renderSnapshots = [];
}
@@ -2588,12 +2589,17 @@ 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);
}
}
@@ -3450,9 +3456,13 @@ 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