From f2b5124d54d442641e59f2dacd272744ad7554bf Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Thu, 9 Oct 2014 22:09:28 +0200 Subject: [PATCH] Changed pager spinner to be smoother --- public_html/js/PresenterManager.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/public_html/js/PresenterManager.js b/public_html/js/PresenterManager.js index 7132f483..5e59e7f6 100644 --- a/public_html/js/PresenterManager.js +++ b/public_html/js/PresenterManager.js @@ -18,22 +18,21 @@ App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboar } function showContentSpinner() { - $spinner.show(); + if (spinnerTimeout !== null) { + spinnerTimeout = window.setTimeout(function() { + $spinner.show(); + }, 150); + } } function hideContentSpinner() { + window.clearTimeout(spinnerTimeout); + spinnerTimeout = null; $spinner.hide(); } function switchContentPresenter(presenter, args) { - var contentPresenterLoaded = function() { - window.clearTimeout(spinnerTimeout); - hideContentSpinner(); - }; - - spinnerTimeout = window.setTimeout(function() { - showContentSpinner(); - }, 100); + showContentSpinner(); if (lastContentPresenter === null || lastContentPresenter.name !== presenter.name) { if (lastContentPresenter !== null && lastContentPresenter.deinit) { @@ -42,10 +41,10 @@ App.PresenterManager = function(jQuery, promise, topNavigationPresenter, keyboar keyboard.reset(); topNavigationPresenter.changeTitle(null); topNavigationPresenter.focus(); - presenter.init.call(presenter, args, contentPresenterLoaded); + presenter.init.call(presenter, args, hideContentSpinner); lastContentPresenter = presenter; } else if (lastContentPresenter.reinit) { - lastContentPresenter.reinit.call(lastContentPresenter, args, contentPresenterLoaded); + lastContentPresenter.reinit.call(lastContentPresenter, args, hideContentSpinner); } }