summaryrefslogtreecommitdiffstats
path: root/js/gui
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-11-18 10:47:51 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2014-11-18 10:47:51 +0100
commit29df1ec667ba16cff222c859dfd6e8f999e4b3b9 (patch)
treef254f8bf5826850458c441ee38dee0e92204071b /js/gui
parentb164a270f91b6490883e3b1136dfdf1641d44326 (diff)
only scroll to active navigation entry when it is not in view, if debug mode is defined, dont included minified scripts
Diffstat (limited to 'js/gui')
-rw-r--r--js/gui/KeyboardShortcuts.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/js/gui/KeyboardShortcuts.js b/js/gui/KeyboardShortcuts.js
index df02f2fd3..41bc77e82 100644
--- a/js/gui/KeyboardShortcuts.js
+++ b/js/gui/KeyboardShortcuts.js
@@ -34,7 +34,20 @@
);
};
- var scrollToNavigationElement = function (elem, scrollArea) {
+ var isInScrollView = function (elem, scrollArea) {
+ // offset().top adds the navigation bar too so we have to subract it
+ var elemTop = elem.offset().top - scrollArea.offset().top;
+ var elemBottom = elemTop + elem.height();
+
+ var areaBottom = scrollArea.height();
+
+ return elemTop >= 0 && elemBottom < areaBottom;
+ };
+
+ var scrollToNavigationElement = function (elem, scrollArea, toTop) {
+ if (elem.length === 0 || (!toTop && isInScrollView(elem, scrollArea))) {
+ return;
+ }
scrollArea.scrollTop(
elem.offset().top - scrollArea.offset().top + scrollArea.scrollTop()
);
@@ -42,7 +55,7 @@
var scrollToActiveNavigationEntry = function (navigationArea) {
var element = navigationArea.find('.active');
- scrollToNavigationElement(element, navigationArea.children('ul'));
+ scrollToNavigationElement(element, navigationArea.children('ul'), true);
};
var reloadFeed = function (navigationArea) {