An alternative to setTimeout?

I have a sapui5 table and I called the scroll function on the table scroll bar. It only works when I use setTimeout

. I am guessing that since the data in the table is loading a little after actually loading the table.

Here is the code I have:

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);

      

I've tried using the function onAfterRendering

as an alternative, but I can't seem to get this to work. Does anyone know of an alternative setTimeout

?

Here is my JSBin .

+3


source to share


1 answer


If it is sap.m.Table you can use updateFinished event from sap.m.ListBase:
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

      

+1


source







All Articles