2

I encounter a problem when i want to use the scrollTo function of the scroller component.

When i execute this command (by a button located on an another panel) :

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

My panel is scrolling only if just before, i have scroll it manually by touching the screen. It's like i have lost focus on the scroller.

Someone have an idea of where is the problem ?

Thank you.

pushreset
  • 95
  • 1
  • 7

1 Answers1

6

That's because the scoller doesn't know the boundaries of its wrapped widget.

Solution:

 if (myPanel.scroller.offsetBoundary.top == 0) {
        myPanel.scroller.updateBoundary();
    }
stan229
  • 2,592
  • 19
  • 23
  • Could you add more of a description as to why you have to manually update the boundary. Is it because the panel hasn't been scrolled at all yet so it just doesn't know the boundary and the boundary will only get updated by a touch event? – Ballsacian1 Jul 02 '11 at 21:36
  • I think it's when you do a scrollTo, it's just a CSS effect. You have to tell to sencha to update boundaries to know where you are now. – pushreset Jul 08 '11 at 10:18
  • Unfortunately, `offsetBoundary` is deprecated since Sencha Touch 2.0.0 and not available anymore. The replacement, `refresh`, does not work. So I ended up doing it with a hack like in http://stackoverflow.com/questions/17714149/auto-scroll-to-the-bottom-of-container-in-sencha-touch-2/17714417#17714417. – Tobias Oct 19 '15 at 17:10