Commit 4fcc4828 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix scrolling to section when clicking in guide TOC.

A regression caused by changing the guide container into panel.

Removed click handlers for guide - these simply didn't do anything
useful - the first one saved incorrect scroll state and the next one was
never triggered.  Planning to fix that in the commits to follow...
parent 85460d01
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -57,19 +57,6 @@ Ext.define('Docs.controller.Guides', {
                        delegate: '.guide'
                    });
                }
            },
            '#guide': {
                afterrender: function(cmp) {
                    cmp.el.addListener('click', function(event, el) {
                        this.setScrollState(this.activeUrl, el.scrollTop);
                    }, this);
                    cmp.el.addListener('click', function(event, el) {
                        this.handleUrlClick(el.href, event);
                    }, this, {
                        preventDefault: true,
                        delegate: '.toc a'
                    });
                }
            }
        });
    },
+17 −3
Original line number Diff line number Diff line
@@ -27,13 +27,27 @@ Ext.define('Docs.view.guides.Container', {
    scrollToEl: function(id) {
        var el = Ext.get(id);
        if (el) {
            var scrollOffset = el.getY() - 100;
            var currentScroll = this.getEl().getScroll()['top'];
            this.getEl().scrollTo('top', currentScroll + scrollOffset);
            this.setScrollTop(this.getScrollTop() + el.getY() - 100);
            el.highlight();
        }
    },

    /**
     * Returns the amount of vertical scroll
     * @return {Number}
     */
    getScrollTop: function() {
        return this.body.getScroll()['top'];
    },

    /**
     * Scrolls vertically to given offset
     * @param {Number} offset
     */
    setScrollTop: function(offset) {
        return this.body.scrollTo('top', offset);
    },

    /**
     * Scrolls guide to the top
     */