PDA

View Full Version : Modify scroll animation



Ayame
15 Sep 2011, 3:51 AM
Is it possible to add more / less easing to the standard Sencha scroll animation? If so, any idea how?

Thanks!

AndreaCammarata
15 Sep 2011, 4:47 AM
Hi Ayame.
I suggest you to take a look at the Ext.util.Scroller component doc:

http://dev.sencha.com/deploy/touch/docs/?class=Ext.util.Scroller

As you can see there are some config params you can "play" with (accelleration, friction, etc.) to make the scroller acts like you want.
So, if you want to changes this params for every Sencha component that use the scroller, you should ovveride the default params in this way:



Ext.override(Ext.util.Scroller, {
accelleration: 50,
friction: 0.2
});


Hope this helps.

Ayame
15 Sep 2011, 4:56 AM
That does indeed seem to point me in the right direction, I'll give that a shot, thanks!

One more thing: can I invoke scrolling upon the click of a button? In jQuery there's a .scrollTo() function, is there something similar in Sencha but then on the x axis as well instead of just the y?

Thanks!

AndreaCammarata
15 Sep 2011, 5:06 AM
Sure!
Suppose you have a vertical scrollable Ext.Panel defined inside a "pnl" variable.
To scroll the panel to the top, just write



pnl.scroller.scrollTo({x:0, y:0}, true);


the first param is an Object that accept the new coordinates, and the second param (in this case true) say if the scroller has to be animated to reach his new position.

Hope this helps.

Ayame
15 Sep 2011, 5:13 AM
Superb! Thanks