From a561cbc5fa0bd2eb4c95b9fdab925414ba7a3e25 Mon Sep 17 00:00:00 2001 From: Wojciech Zawistowski Date: Mon, 31 Mar 2014 17:56:23 +0200 Subject: [PATCH] Delays loading spinner when switching between tabs. --- .../javascripts/discourse/routes/discovery_route.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/routes/discovery_route.js b/app/assets/javascripts/discourse/routes/discovery_route.js index 15a1df58386..e903ffdf749 100644 --- a/app/assets/javascripts/discourse/routes/discovery_route.js +++ b/app/assets/javascripts/discourse/routes/discovery_route.js @@ -10,11 +10,18 @@ Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.OpenComposer, { actions: { loading: function() { - this.controllerFor('discovery').set('loading', true); + var controller = this.controllerFor('discovery'); + + controller.set('scheduledSpinner', Ember.run.later(controller, function() { + this.set('loading', true); + },500)); }, loadingComplete: function() { - this.controllerFor('discovery').set('loading', false); + var controller = this.controllerFor('discovery'); + + Ember.run.cancel(controller.get('scheduledSpinner')); + controller.set('loading', false); }, didTransition: function() {