From 996d12814644592c9ab8cba13ab3611d9dabd655 Mon Sep 17 00:00:00 2001 From: "aa@chromium.org" Date: Thu, 23 Sep 2010 17:48:02 +0000 Subject: NTP: Don't show any sections or layout until we receive mv and apps data. This improves performance and avoids flickeryness. BUG=56278 TEST=Install some apps and refresh the ntp over and over. Should not see flickering as mv section, then apps load. Review URL: http://codereview.chromium.org/3474006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60306 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/resources/ntp/apps.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'chrome/browser/resources/ntp/apps.js') diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js index 7d30f9e..057ca6a 100644 --- a/chrome/browser/resources/ntp/apps.js +++ b/chrome/browser/resources/ntp/apps.js @@ -13,22 +13,27 @@ function getAppsCallback(data) { if (data.apps.length == 0) { appsSection.classList.add('disabled'); setShownSections(Section.THUMB); - return; - } + } else { + data.apps.forEach(function(app) { + appsSectionContent.appendChild(apps.createElement(app)); + }); - data.apps.forEach(function(app) { - appsSectionContent.appendChild(apps.createElement(app)); - }); + appsSectionContent.appendChild(apps.createWebStoreElement()); - appsSectionContent.appendChild(apps.createWebStoreElement()); + data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) { + appsMiniview.appendChild(apps.createMiniviewElement(app)); + }); - data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) { - appsMiniview.appendChild(apps.createMiniviewElement(app)); - }); + appsSection.classList.remove('disabled'); + } + + apps.loaded = true; + maybeDoneLoading(); - appsSection.classList.remove('disabled'); - updateMiniviewClipping(appsMiniview); - layoutSections(); + if (data.apps.length > 0 && isDoneLoading()) { + updateMiniviewClipping(appsMiniview); + layoutSections(); + } } var apps = (function() { @@ -143,6 +148,8 @@ var apps = (function() { }); return { + loaded: false, + createElement: function(app) { var div = createElement(app); var a = div.firstChild; -- cgit v1.1