angular-ui / ui-scroll

Unlimited bidirectional scrolling over a limited element buffer for AngularJS applications

Home Page:http://angular-ui.github.io/ui-scroll/demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Index increments without scrolling

ranst91 opened this issue · comments

So. I implemented ui-scroll
I have a list containing about 20 items. The buffer size is set to about 8-12 items (as of 12 items, scrolling will be enabled as only 9 items fit in the viewport).
On initialization (refresh, entering page etc). All items are fetched, and they are all shown.

Loging the requested index on the "get" method shows that the "index" argument just increments (without scrolling or touching the page) until it reaches the maximum of items.

I expect the a scroll event to trigger this behavior, rather than this behavior triggers itself for no reason.

My "get" function returns new array out of an array of already fetched data:

        const broadcasts = this.broadcasts.filter(broadcast => !broadcast.blacklisted);
        setTimeout(() => {
            const result = [];
            for (let i = index; i <= index + count - 1; i++) {
                if (broadcasts[i])
                    result.push(broadcasts[i]);
            }

            success(result);
        }, 100);
    }

Please ignore it's name, as it's being referenced (so eventually its the get method)

It seems like this issue is introduced when using a grid.
On the one hand, the described above is "fixed" (or at least, understood), on the other hand, if it only works on single row items, it is not as helpful...

Closing.