diff options
author | Phil Hughes <me@iamphill.com> | 2017-04-20 15:56:52 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-04-20 15:56:52 +0100 |
commit | 7d7a0b2c5f534cd78e3239de7c936bd6f23e1bc7 (patch) | |
tree | d428086afa1ff698ed737c3b2cbb7235861d48d1 /app/assets/javascripts/right_sidebar.js | |
parent | f09f753908a001e791a254d277032734f6fe57b6 (diff) | |
download | gitlab-ce-diff-perf.tar.gz |
Merge request performance improvementsdiff-perf
Diffstat (limited to 'app/assets/javascripts/right_sidebar.js')
-rw-r--r-- | app/assets/javascripts/right_sidebar.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/app/assets/javascripts/right_sidebar.js b/app/assets/javascripts/right_sidebar.js index a9b3de281e1..f287f6df384 100644 --- a/app/assets/javascripts/right_sidebar.js +++ b/app/assets/javascripts/right_sidebar.js @@ -8,7 +8,13 @@ import Cookies from 'js-cookie'; this.Sidebar = (function() { function Sidebar(currentUser) { this.toggleTodo = bind(this.toggleTodo, this); + this.window = window; this.sidebar = $('aside'); + this.navBar = document.querySelector('.navbar-gitlab'); + this.layoutNav = document.querySelector('.layout-nav'); + this.rightSidebar = document.querySelector('.js-right-sidebar'); + this.navHeight = this.navBar.clientHeight + this.layoutNav.clientHeight + 1; + this.setSidebarHeight(); this.removeListeners(); this.addEventListeners(); } @@ -23,7 +29,7 @@ import Cookies from 'js-cookie'; Sidebar.prototype.addEventListeners = function() { const $document = $(document); - const throttledSetSidebarHeight = _.throttle(this.setSidebarHeight, 10); + const throttledSetSidebarHeight = this.setSidebarHeight.bind(this); this.sidebar.on('click', '.sidebar-collapsed-icon', this, this.sidebarCollapseClicked); $('.dropdown').on('hidden.gl.dropdown', this, this.onSidebarDropdownHidden); @@ -209,14 +215,10 @@ import Cookies from 'js-cookie'; }; Sidebar.prototype.setSidebarHeight = function() { - const $navHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight() + $('.sub-nav-scroll').outerHeight(); - const $rightSidebar = $('.js-right-sidebar'); - const diff = $navHeight - $(window).scrollTop(); - if (diff > 0) { - $rightSidebar.outerHeight($(window).height() - diff); - } else { - $rightSidebar.outerHeight('100%'); - } + let diff = this.navHeight - this.window.scrollY; + diff = diff < 0 ? 0 : diff; + + this.rightSidebar.style.transform = `translateY(${diff}px)`; }; Sidebar.prototype.isOpen = function() { |