PDA

View Full Version : Event scroll list



dbottillo
17 Sep 2010, 7:47 AM
Hi,

i have to get the event fired when user scroll down a list
assuming i have 10 elements on a list and only 5 visible, when user scroll down to see the other elements i want to get this event (to put more elements inside list)

i try



listeners: {
scroll: addelement2,
onscroll: addelement2,
onscrolldown: addelement2,
}

but none of this work...!
in documentation i didn't see this event...how can i do?

Daniele

evant
19 Sep 2010, 8:05 PM
Listen to the scroll event of the scroller:



panel.scroller.on('scroll', ....);

dbottillo
23 Sep 2010, 6:39 AM
i try

list.scroller.on('scroll', loadMoreList('50'));

loadMoreList will execute one times (and when the list is loaded not when user scroll down!!!), and also after i receive a lot of errors like:
'Uncaught TypeError: Cannot call method 'apply' of undefined'

it seems that it fires this event too many other times...
i want to launch 'loadMoreList' when user START to scroll down and just one time

aconran
23 Sep 2010, 2:54 PM
i try

list.scroller.on('scroll', loadMoreList('50'));



You are executing this code immediately at definition time... You probably want something more like:

list.scroller.on('scroll', function() {
loadMoreList('50');
});

The scroll event is going to fire continuously as you scroll the panel, therefore you probably want to buffer the events so that it only happens after a certain threshold of time.

list.scroller.on('scroll', function() {
loadMoreList('50');
}, this, {buffer: 200});

Alternatively, you could check to see when they have scrolled close to the bottom of the current visible area.

dbottillo
24 Sep 2010, 12:01 AM
Alternatively, you could check to see when they have scrolled close to the bottom of the current visible area.

And how can i check this case?

anyway thanks for reply!!

Daniele

aconran
24 Sep 2010, 9:24 AM
list.scroller.on('scroll', function(scroller, offsets) {
var distanceToEnd = scroller.size.height - offsets.y - scroller.parentSize.height;
if (distanceToEnd < 300) {
console.log('within 300px of bottom');
}
}, this, {buffer: 300});

dbottillo
27 Sep 2010, 2:38 AM
thank you

it works perfectly