PDA

View Full Version : how to use scrollTo or scroll functions???



adms
4 Jul 2011, 3:31 AM
hi ,
i have the following code, i'm trying to scroll or move the position of the label to a specified position, but it doesn't work!!,


var label = new Ext.form.Label({
text:'try animation',
renderTo:Ext.getBody()
});
var butt = new Ext.Button({
text:'animate',
renderTo:Ext.getBody(),
handler:function(){
label.el.scroll('right',200); // scroll not work ,why???
label.setPosition(200,200); // setPosition not work ,why???
}
});

Uberdude
4 Jul 2011, 6:20 AM
scroll and scrollTo are not what you want: they are used to scroll the view of an element (as if you used the scrollbars).

If you want to make elements fly across the page with smooth animations (as opposed to instantly jumping there, which is what setPosition would do if you got it to work), use the functions from Ext.Fx, which are available on Element:



handler: function(){
label.el.shift({
x: 200,
y: 200,
duration: 1
});
}

adms
4 Jul 2011, 10:11 PM
thank you very mush,
now it works fine;)