PDA

View Full Version : Element not scrollable, how to make it scroll?



mitchellsimoens
29 Dec 2010, 7:25 AM
I'm trying to scroll to the absolute top of the page but am unsuccessful. I have tried


Ext.getBody().isScrollable();
Ext.get(document.body).isScrollable();
Ext.get("app-div").isScrollable();

but it always returns false. How do I enable scrolling?

Condor
29 Dec 2010, 7:44 AM
isScrollable doesn't work correctly on the body, because it is using dom.clientHeight when it should be using getViewSize.

But that doesn't stop you from setting scrollTop to 0.

mitchellsimoens
29 Dec 2010, 7:49 AM
Understand that explaination.

This doesn't work even tho I thought it would:

Ext.getBody().scrollTo("top", 0);

I have a DIV at the very top and I couldn't scrollIntoView on that EL either.

Condor
29 Dec 2010, 7:51 AM
Yes, scrollTo won't work either.

You could use:

if (Ext.isIE && Ext.isStrict) {
document.documentElement.scrollTop = 0;
} else {
document.body.pageYOffset = 0;
}

mitchellsimoens
29 Dec 2010, 7:58 AM
After your edit it works =D> ;)

Thanks Condor!