From 341a28402df2e7e8a4e73c8a7cd440301cf37732 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 20 Aug 2013 10:35:02 +1000 Subject: [PATCH] speed up scrolling on android --- .../javascripts/discourse/views/topic_view.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/views/topic_view.js b/app/assets/javascripts/discourse/views/topic_view.js index b07c638cac..176cf6060a 100644 --- a/app/assets/javascripts/discourse/views/topic_view.js +++ b/app/assets/javascripts/discourse/views/topic_view.js @@ -25,10 +25,19 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, { }.observes('controller.streamPercentage'), updateProgressBar: function() { - var $topicProgress = $('#topic-progress'); - if (!$topicProgress.length) return; + var $topicProgress = this.topicProgress; - var totalWidth = $topicProgress.width(); + // cache lookup + if (!$topicProgress) { + $topicProgress = $('#topic-progress'); + if (!$topicProgress.length) { + return; + } + this.topicProgress = $topicProgress; + } + + // speeds up stuff, bypass jquery slowness and extra checks + var totalWidth = $topicProgress[0].offsetWidth; var progressWidth = this.get('controller.streamPercentage') * totalWidth; $topicProgress.find('.bg')