Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

updateLayout() causing parent container to scroll to top

calling updateLayout() is causing the parent container to "jump" to the top. Setting the viewconfig on the Ext.Container.container does not seem to help

viewConfig: {
    preserveScrollOnRefresh: true
},
like image 777
Shain Padmajan Avatar asked Aug 12 '16 07:08

Shain Padmajan


2 Answers

As suggested by Alexander, overriding beforeLayout and afterLayout for the parent container did the trick.

beforeLayout: function() {
    var me = this,
        scroller = me.getScrollable();
    me.callParent(arguments);
    if (scroller) {
        me.savedScrollPos = scroller.getPosition();
    }
},
afterLayout: function() {
    var me = this,
        scroller = me.getScrollable();
    me.callParent(arguments);
    if (scroller && me.savedScrollPos) {
        scroller.scrollTo(me.savedScrollPos);
    }
},
like image 74
Shain Padmajan Avatar answered Nov 04 '22 20:11

Shain Padmajan


updateLayout is not the same as refresh, and preserveScrollOnRefresh only preserves scroll on refresh. You could look into ExtJS code how they did it (they don't really "preserve" scroll, they store the scroll position and scroll back to the correct position after refresh) and implement the same for updateLayout.

like image 27
Alexander Avatar answered Nov 04 '22 21:11

Alexander