Node.js based forum software built for the modern web
Tweaked scrollToPostIndex logic
Julian Lam5d4f61ec96d4
diff --git a/package.json b/package.jsonindex 286e4e712d..016b488605 100644--- a/package.json+++ b/package.json@@ -53,8 +53,8 @@"nodebb-plugin-spam-be-gone": "0.4.6","nodebb-rewards-essentials": "0.0.8","nodebb-theme-lavender": "3.0.9",- "nodebb-theme-persona": "4.0.112",- "nodebb-theme-vanilla": "5.0.59",+ "nodebb-theme-persona": "4.0.113",+ "nodebb-theme-vanilla": "5.0.60","nodebb-widget-essentials": "2.0.8","nodemailer": "2.0.0","nodemailer-sendmail-transport": "1.0.0",diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.jsindex 3ac5fc16e2..f6ac8c628a 100644--- a/public/src/modules/navigator.js+++ b/public/src/modules/navigator.js@@ -190,7 +190,12 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com};navigator.scrollToPostIndex = function(postIndex, highlight, duration) {- var scrollTo = components.get('post/anchor', postIndex);+ var scrollTo = components.get('post/anchor', postIndex),+ postEl = components.get('post', 'index', postIndex),+ postHeight = postEl.height(),+ viewportHeight = $(window).height(),+ navbarHeight = components.get('navbar').height();+if (!scrollTo.length) {navigator.scrollActive = false;@@ -202,7 +207,12 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, comvar done = false;function animateScroll() {- var scrollTop = (scrollTo.offset().top - ($(window).height() / 2)) + 'px';+ var scrollTop = 0;+ if (postHeight < viewportHeight) {+ scrollTop = (scrollTo.offset().top - (viewportHeight / 2) + (postHeight / 2)) + 'px';+ } else {+ scrollTop = scrollTo.offset().top - navbarHeight;+ }$('html, body').animate({scrollTop: scrollTop