PDA

View Full Version : An easy way to custom scroll through a panel?



darren
29 Jan 2010, 11:10 AM
I have a panel that I am trying to use as a fancy menu system using icons. I want to have an image on the left so when I click it, it scrolls left smoothly. I want the same with an image on the right. Has anything in ExtJS been done like this? Also do you know what animation I would use to do the smooth scrolling? Thanks

darren
29 Jan 2010, 1:27 PM
I've made a function in case anyone else wants to use it:


function scroller(direction, element) {
if (direction == 'left' || direction == 'right') {
var el = Ext.get(element);
if (direction == 'left') {
if (el.getScroll().left > 0) {
var position = el.getScroll().left - 128;
el.scrollTo('left', position, true);
}
}
if (direction == 'right') {
if (el.getScroll().left < el.getWidth()) {
var position = el.getScroll().left + 128;
el.scrollTo('right', position, true);
}
}
}
}