diff options
-rw-r--r-- | app/assets/javascripts/layout_nav.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/assets/javascripts/layout_nav.js b/app/assets/javascripts/layout_nav.js index ab95009b9b8..8e2fc0d1479 100644 --- a/app/assets/javascripts/layout_nav.js +++ b/app/assets/javascripts/layout_nav.js @@ -29,13 +29,16 @@ var $this = $(this), scrollingTabWidth = $this.width(), $active = $this.find('.active'), - activeWidth = $active.width(), - offset = $active.offset().left + activeWidth; + activeWidth = $active.width(); - if (offset > scrollingTabWidth - 30) { - var scrollLeft = scrollingTabWidth / 2; - scrollLeft = (offset - scrollLeft) - (activeWidth / 2); - $this.scrollLeft(scrollLeft); + if ($active.length) { + var offset = $active.offset().left + activeWidth; + + if (offset > scrollingTabWidth - 30) { + var scrollLeft = scrollingTabWidth / 2; + scrollLeft = (offset - scrollLeft) - (activeWidth / 2); + $this.scrollLeft(scrollLeft); + } } }); }); |