diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js index 47cdc20ccf..91e5ccf9ae 100644 --- a/apps/common/main/lib/component/DataView.js +++ b/apps/common/main/lib/component/DataView.js @@ -1103,6 +1103,21 @@ define([ focusInner: function(e) { this.focus(e.keyCode == Common.UI.Keys.DOWN ? 'first' : 'last'); + }, + + childWillBeVisibleAtScroll: function(index, scrollPosition) { + var child = this.dataViewItems[index]; + if (!child) { + return false; + } + + var $childEl = child.$el.first(); + var $containerEl = $(this.el).first(); + + var elementOffset = $childEl.offset().top - $containerEl.offset().top + $containerEl.scrollTop(); + var viewportHeight = scrollPosition + $containerEl.height() + $childEl.outerHeight(); + + return elementOffset - scrollPosition > 0 && elementOffset <= viewportHeight; } }); diff --git a/apps/documenteditor/main/app/controller/Navigation.js b/apps/documenteditor/main/app/controller/Navigation.js index 14be80b3e9..48b790a17a 100644 --- a/apps/documenteditor/main/app/controller/Navigation.js +++ b/apps/documenteditor/main/app/controller/Navigation.js @@ -170,21 +170,36 @@ define([ } var me = this; + this._scrollTop = me.panelNavigation.viewNavigationList.scroller.getScrollTop(); + var store = this.getApplication().getCollection('Navigation'); store.reset(arr.splice(0, 50)); this._currentPos = this._navigationObject.get_CurrentPosition(); + function checkScrollFocus() { + if (me._currentPos > -1 && me._currentPos < store.length) { + if (me._scrollTop > 0 && me.panelNavigation.viewNavigationList.childWillBeVisibleAtScroll(me._currentPos, me._scrollTop)) { + me.panelNavigation.viewNavigationList.scroller.scrollTop(me._scrollTop); + me.panelNavigation.viewNavigationList.selectByIndex(me._currentPos); + } else { + me.onChangeOutlinePosition(me._currentPos); + me._currentPos = -1; + } + } + } + function addToPanel() { if (arr.length<1) { if (me.timerUpdateId) { clearTimeout(me.timerUpdateId); me.timerUpdateId = 0; } + me.panelNavigation.viewNavigationList.scroller && me.panelNavigation.viewNavigationList.scroller.update({alwaysVisibleY: true}); - if (me._currentPos>-1 && me._currentPos-1 && me._currentPos