diff options
author | Phil Hughes <me@iamphill.com> | 2016-09-16 13:52:06 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-09-16 13:52:06 +0100 |
commit | 473684847ec79b870f182003a6dbed98cb6cd254 (patch) | |
tree | fc98acd3de7741f817da3ec2d29b82b59642c80e /app | |
parent | c04ef86c644cab2cd620df9dd7ab3ddafab1f80f (diff) | |
download | gitlab-ce-473684847ec79b870f182003a6dbed98cb6cd254.tar.gz |
Doesnt run JS if active element doesnt existscrolling-tabs-center-mobile
Diffstat (limited to 'app')
-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); + } } }); }); |