From 104e5c6557707b13307802dd3b9c87d0209d4a92 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 27 Feb 2013 22:27:49 +0400 Subject: [PATCH] moveToPost: implement more natural next/prev moving in combined mode --- js/viewfeed.js | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/js/viewfeed.js b/js/viewfeed.js index 07af91a6..6f88f7ea 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -549,13 +549,23 @@ function moveToPost(mode) { } if (mode == "next") { - if (next_id) { + if (next_id || active_post_id) { if (isCdmMode()) { - cdmExpandArticle(next_id); - cdmScrollToArticleId(next_id); + var article = $("RROW-" + active_post_id); + var ctr = $("headlines-frame"); - } else { + if (article && article.offsetTop + article.offsetHeight > + ctr.scrollTop + ctr.offsetHeight) { + + scrollArticle(ctr.offsetHeight/2); + + } else if (next_id) { + cdmExpandArticle(next_id); + cdmScrollToArticleId(next_id); + } + + } else if (next_id) { correctHeadlinesOffset(next_id); view(next_id, getActiveFeedId()); } @@ -563,11 +573,23 @@ function moveToPost(mode) { } if (mode == "prev") { - if (prev_id) { + if (prev_id || active_post_id) { if (isCdmMode()) { - cdmExpandArticle(prev_id); - cdmScrollToArticleId(prev_id); - } else { + + var article = $("RROW-" + active_post_id); + var prev_article = $("RROW-" + prev_id); + var ctr = $("headlines-frame"); + + if (article && article.offsetTop < ctr.scrollTop) { + scrollArticle(-ctr.offsetHeight/2); + } else if (prev_article && prev_article.offsetTop < ctr.scrollTop) { + cdmExpandArticle(prev_id); + scrollArticle(-ctr.offsetHeight/2); + } else if (prev_id) { + cdmExpandArticle(prev_id); + cdmScrollToArticleId(prev_id); + } + } else if (prev_id) { correctHeadlinesOffset(prev_id); view(prev_id, getActiveFeedId()); } -- 2.39.5