PDA

View Full Version : scroll element not work



lechuck
28 Jun 2007, 9:53 AM
That suppose to scroll the element to the bottom.

Ext.get('center-div').scroll('b', 0, true);

I use Ext.BorderLayout to create the layout and use prototype library to fill the div 'center-div'. But when I call scroll function it does not work.

This is the function that receive the Ajax response


getMessage:function(response)
{
if(response.responseText.blank() === false)
{
new Insertion.Bottom('east-div' ,'<hr>' + response.responseText.escapeHTML());

t = response.responseText.split('{||}');
for(var n=0; n < t.length; n++)
{
cols = t[n].split('{|}');
if(cols.length > 1)
{
var newid = cols[0].replace(' ', '');
member = cols[1];
if(newid != undefined && this.lastid.indexOf(newid) == -1)
{
new Insertion.Bottom('center-content' ,cols[2]);
this.lastid.push(newid);
new Effect.Highlight('pbcchat_'+newid);
Ext.get('center-div').scroll('b', 0, true);

}
}
}
}
}


Please any help with that?
I'm a newbie with Ext library

thanks

Peter.Ivanov
9 Aug 2007, 3:10 AM
i have the same problem too, anyone with solution?

Animal
9 Aug 2007, 4:25 AM
You're asking it to scroll zero pixels down.

Animal
9 Aug 2007, 4:31 AM
What I think you need is an enhanced version of scrollTo which can use "right" or "bottom" as the first parameter and scrolls to n pixels from the specified side.



Ext.override(Ext.Element, {
scrollTo : function(side, value, animate){
var side = side.toLowerCase();
var prop;
switch (side) {
case "left":
prop = "scrollLeft";
break;
case "right":
prop = "scrollLeft";
value = this.dom.scrollWidth - (value + this.dom.clientWidth);
break;
case "top":
prop = "scrollTop";
break;
case "bottom":
prop = "scrollTop";
value = this.dom.scrollHeight - (value + this.dom.clientHeight);
break;
}
if (value < 0) value = 0;
if(!animate || !A){
this.dom[prop] = value;
}else{
var to = prop == "scrollLeft" ? [value, this.dom.scrollTop] : [this.dom.scrollLeft, value];
this.anim({scroll: {"to": to}}, this.preanim(arguments, 2), 'scroll');
}
return this;
}
});