From d3c682449598cc123713e84d0de39b3abef336dd Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Fri, 17 Jan 2014 00:15:36 -0800 Subject: [PATCH] Prevents the little horizontal jostle that happens in the detail page when you press 'right' the first time. Change-Id: Ic39607258c056bcee898463ef4ed80cc64799baf --- server/camlistored/ui/index.css | 3 --- server/camlistored/ui/index.js | 11 +++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server/camlistored/ui/index.css b/server/camlistored/ui/index.css index ba183586a..57061a8d8 100644 --- a/server/camlistored/ui/index.css +++ b/server/camlistored/ui/index.css @@ -27,9 +27,6 @@ body { .cam-index-page { font: 16px/1.4 normal Arial, sans-serif; - /* It makes it easier to compute the layout of the aligned tiles if the - scrollbar is reliably on */ - overflow-y: scroll; } .cam-index-title { diff --git a/server/camlistored/ui/index.js b/server/camlistored/ui/index.js index e0f6f96b0..f3be1e612 100644 --- a/server/camlistored/ui/index.js +++ b/server/camlistored/ui/index.js @@ -81,6 +81,7 @@ cam.IndexPage = function(config, opt_domHelper) { this.savedScrollPosition_ = 0; this.inDetailMode_ = false; + this.inSearchMode_ = false; this.detail_ = null; this.detailLoop_ = null; this.detailViewHost_ = null; @@ -333,15 +334,16 @@ cam.IndexPage.prototype.handleURL_ = function(newURL) { // This is super finicky. We should improve the URL scheme and give things that are different different paths. var query = newURL.getQueryData(); - var inSearchMode = query.getCount() == 0 || (query.getCount() == 1 && query.containsKey('q')); + this.inSearchMode_ = query.getCount() == 0 || (query.getCount() == 1 && query.containsKey('q')); this.inDetailMode_ = query.containsKey('p') && query.get('newui') == '1'; - if (!inSearchMode && !this.inDetailMode_) { + if (!this.inSearchMode_ && !this.inDetailMode_) { return false; } this.currentURL_ = newURL; this.updateSearchSession_(); + this.updateScrollbar_(); this.updateSearchView_(); this.updateDetailView_(); return true; @@ -369,6 +371,11 @@ cam.IndexPage.prototype.updateSearchSession_ = function() { this.searchSession_ = new cam.SearchSession(this.connection_, new goog.Uri(location.href), query); }; +cam.IndexPage.prototype.updateScrollbar_ = function() { + // It makes it easier to compute the layout of the aligned tiles if the scrollbar is reliably on. + document.body.style.overflowY = this.inSearchMode_ ? 'scroll' : ''; +}; + cam.IndexPage.prototype.updateSearchView_ = function() { if (this.inDetailMode_) { this.savedScrollPosition_ = goog.dom.getDocumentScroll().y;