PDA

View Full Version : Scroll event manager



asulhyan
4 Jul 2013, 8:31 AM
I am using the document scroll event to manage the position of the another div. The only problem I am facing is if I move the scroll two quickly towards the end scroll events are not invoked. I am not sure if this is due to multiple scroll events getting fired simultaneously - I don't see the issue if I move the scroll slowly always.



Ext.fly(document).on('scroll', function() {
if ( (Ext.getBody().getHeight() + Ext.getBody().getScrollTop() - 50 ) < Ext.getCmp('projectionChart').getHeight() ) {
Ext.get('projectionChart').setStyle("top", 42-Ext.getBody().getScrollTop() + 'px');
}
});

slemmon
8 Jul 2013, 11:04 AM
What browser or browsers are you seeing the issue?

asulhyan
8 Jul 2013, 11:28 AM
You can use this example. I can see it in chrome, FF. If you move the scroll slowly you will see "scroll called" is printed about 168 times. The count is not consistent - especially if you move too quickly.

http://jsfiddle.net/abhijitsulhyan/jaBmH/


What browser or browsers are you seeing the issue?

asulhyan
8 Jul 2013, 12:48 PM
You can ignore this. I recognized this was consistent with Window.onScroll(...) . Also, it was much cleaner to do something like this in else part - that way I don't need to worry about how many times the scroll events get fired... Thanks for looking into it



if (...){
... same as above
} else {
Ext.get(cmp.id).setStyle("top", (Ext.getBody().getHeight() - Ext.getCmp(cmp.id).getHeight()) + 'px');
}



You can use this example. I can see it in chrome, FF. If you move the scroll slowly you will see "scroll called" is printed about 168 times. The count is not consistent - especially if you move too quickly.

http://jsfiddle.net/abhijitsulhyan/jaBmH/