替代setTimeout?

时间:2015-07-31 13:52:04

标签: javascript jquery settimeout sapui5

我有一个sapui5表,我在表滚动条上调用了一个滚动函数。它仅在我使用@n时有效。我假设这是因为表中的数据在实际表加载后会略微加载。

这是我的代码:

<pb/>

我曾尝试使用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); 的替代方案?

这是我的JSBin

1 个答案:

答案 0 :(得分:1)

如果这是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