PDA

View Full Version : Detect which items of list are visible?



konki_vienna
22 Oct 2010, 6:27 AM
SenchaTouch 0.97beta & iPad:

I have the following problem:

I have around 500 data-items for a store. To add them at once to the store/related list takes much too long (more than 15 seconds!!!).
So I am looking for a workaround for this problem.

My suggestion is to add data to the connected store when the user scrolls to the bottom of the list.
Is there a way to detect that the user is going to scroll to the end of the list in order to add additional data to the store?

So I would need to know the index of the last visible list item of the current list view.

kgilb
24 Oct 2010, 6:54 AM
I would be interested in knowing the answer to this as well.

dbottillo
25 Oct 2010, 12:18 AM
try this:



list.scroller.on('scroll', function(scroller, offsets) {
var distanceToEnd = scroller.size.height - offsets.y - scroller.parentSize.height;
if (distanceToEnd < 300) {
loadMoreDataList();
}
}, this, {buffer: 300});

konki_vienna
25 Oct 2010, 4:15 AM
Fabulous - this was a helpfull tip! Thank you!

Where in the documentation can I find more about the "scroller"-thing? - I would like to update the scrollbar, for instance, when I loaded additional items to the store...

MiamiCoder
25 Oct 2010, 12:29 PM
A word of caution, though. Performance and usability decrease as the number of items in the list increases. Try to use nested lists when you need to present a large number of items.

dbottillo
25 Oct 2010, 1:36 PM
A word of caution, though. Performance and usability decrease as the number of items in the list increases. Try to use nested lists when you need to present a large number of items.

how to achieve the same result but with high perfomance using nested lists?