angular-ui/ui-utils

UI-Scroll how to call revision function manully ?

HeavenGoGo opened this issue · 2 comments

the application may be a little complex, of course the code about ui scroll is simple.just as below

var flag=0;
var getDataAsync=function(){
    $q.when(...).then(function(items){
        for(var I=0;i<items.length;i++){
            scope.items.push(items[i]);
        }
        flag+=1;
    });
};
scope.matchesSource = {
        get: function (index, count, success) {
            return $timeout(function() {
            var results =[];
                var start = Math.max(0, index);
                var end = Math.min(index +count, scope.items.length);

                for (var i = start; i < end; i++) {
                    results.push(scope.items[i]);
                }
                success(results);
            }, 100)
        },
        revision: function () {
            return flag;
        }
 };

Assume that when we click the textbox it first load the scope.items collection asynchronously.

I think because there are some directive make some extra influence, when execute the get method the scope items is empty even though we load data firstly. And although the data items length is not 0, it will not display data also. but when click second the data loaded and display. so if there are some methods to fair revision method manually ?

One more thing, I log the date time of execution of revision function, the ui-scroll execute in a short time, and date items length is 0. when I modify the ui-scroll script as below:

$scope.$watch(datasource.revision, function (value) {
       $timeout(reload);
 });

it just work well, but because the time delay, the data list ui will flicker, I don't think it is a good way.

See my pull request #419

Actual code base of ui-scroll is in https://github.com/Hill30/NGScroller. Please re-submit your issue over there if needed.