我有一个sapui5表,我在表滚动条上调用了一个滚动函数。它只有在我使用setTimeout
时才有效。我假设这是因为表中的数据在实际表加载后稍微加载。
这是我的代码:
setTimeout(function () {
var lastScroll = 0;
$("#__xmlview0--players-vsb-sb").scroll(function () {
var st = $(this).scrollTop();
if (st > lastScroll) {
console.log("scrolling down");
} else {
console.log("scrolling up");
}
lastScroll = st;
});
}, 900);
我试图使用onAfterRendering
函数作为替代,但我不能让它工作。有没有人知道setTimeout
的替代品?
这是我的JSBin。
如果这是sap.m.Table,您可以使用sap.m.ListBase中的updateFinished事件,请参阅: OpenUI5 SDK - Demo Kit v2.0
updateFinished(oControlEvent)
This event is called after items binding and afterwards related DOM is updated.
Parameters:
{sap.ui.base.Event} oControlEvent
{sap.ui.base.EventProvider} oControlEvent.getSource
{object} oControlEvent.getParameters
{string} oControlEvent.getParameters.reason The reason of update. Possible values are "Binding", "Filter", "Sort", "Growing", "Change", "Refresh", "Context"
{int} oControlEvent.getParameters.actual Actual number of items.
{int} oControlEvent.getParameters.total The total count of bound items. This parameter can be used if "growing" feature is enabled.
Since:
1.16.3