PDA

View Full Version : moving an div with duration



linxpinx
1 Jun 2009, 2:16 AM
hi,
i`m really new with extJS. so maybe my question is very simple, but anyway. i try to move a div with duration. in the api documentation for Element is this example:
// animation with some options set
el.setWidth(100, {
duration: 1,
callback: this.foo,
scope: this
});
my code is:
Ext.onReady(function(){
var myDiv = Ext.get('myDiv');
Ext.get("myButton").on('click', function() {
myDiv.move('right',100, {
duration: 10
});
});
});
when i leave the duration my Div moves fine. What did i miss?
I`m using Safari 4 Public Beta and Firefox 3.0.10 on Mac OS X Leopard.
Thanx for your Help.
bernd

Animal
1 Jun 2009, 4:07 AM
What is the problem you are having?

Is it not in fact moving to the new location in 10 milliseconds?

Animal
1 Jun 2009, 4:21 AM
OK, the docs aren't clear. The last 3 args are


duration in seconds
callback
easing


so



myDiv.move('right', 200, 2, function(){console.log("done")}, 'easeBoth')

Animal
1 Jun 2009, 4:32 AM
Actually, it's a bug in Ext.

The move function should be



move : function(direction, distance, animate){
var me = this,
xy = me.getXY(),
x = xy[0],
y = xy[1],
left = [x - distance, y],
right = [x + distance, y],
top = [x, y - distance],
bottom = [x, y + distance],
hash = {
l : left,
left : left,
r : right,
right : right,
t : top,
top : top,
up : top,
b : bottom,
bottom : bottom,
down : bottom
};

direction = direction.toLowerCase();
me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
},

linxpinx
1 Jun 2009, 4:33 AM
thanx for you help, no it works.
to have it clear for me, i had to use all 3 parameters, right? is this true for the whole api documentation? maybe there is another method that had an array of parameters and i have to take all of them even when i wanna use only one.
ciao
bernd
live told me every day that it is more than reality ;)

Animal
1 Jun 2009, 4:38 AM
It's a bug.

Either use the above method in your override, or wait 1 day until RC2 is released.

linxpinx
1 Jun 2009, 6:53 AM
ah thanks.
have a nice day
bernd

crysfel
1 Jun 2009, 7:28 AM
... wait 1 day until RC2 is released.

Great news :D :D