From b43e12a42adfb7ed33cd90e075298d29893efa52 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 21 Aug 2013 19:21:49 -0400 Subject: [PATCH] closes #187, closes #190 --- public/src/app.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index d9f870fe37..eb5e2b51a3 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -342,19 +342,22 @@ var socket, app.scrollToPost = function(pid) { if(!pid) return; + var container = $(document.body), scrollTo = $('#post_anchor_' + pid), tid = $('#post-container').attr('data-tid'); - while(!scrollTo.length) { + while(!scrollTo.length && tid) { app.loadMorePosts(tid, function() { scrollTo = $('#post_anchor_' + pid); }); } - - container.animate({ - scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height() - }); + + if(tid) { + $('body,html').animate({ + scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height() + }); + } } jQuery('document').ready(function() {