angular-ui / ui-scroll

Unlimited bidirectional scrolling over a limited element buffer for AngularJS applications
http://angular-ui.github.io/ui-scroll/demo/
MIT License
327 stars 107 forks source link

Index increments without scrolling #208

Closed ranst91 closed 6 years ago

ranst91 commented 6 years ago

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)

ranst91 commented 6 years ago

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.