From f41ab98e86dc88c5d09534cdc1a8cc06d4e2a0c9 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 24 Apr 2017 16:36:20 -0400 Subject: [PATCH] FIX: Scrolling to the bottom was still a bit weird with no suggested --- .../javascripts/discourse/lib/offset-calculator.js.es6 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/offset-calculator.js.es6 b/app/assets/javascripts/discourse/lib/offset-calculator.js.es6 index 3c2fc1fc71e..81e97e97dd6 100644 --- a/app/assets/javascripts/discourse/lib/offset-calculator.js.es6 +++ b/app/assets/javascripts/discourse/lib/offset-calculator.js.es6 @@ -36,8 +36,12 @@ export default function offsetCalculator(y) { if (inter > ideal) { const bottom = $('#topic-bottom').offset().top; const switchPos = bottom - rawWinHeight; + if (scrollPercent >= 1.0) { + return 0; + } + if (scrollTop > switchPos) { - const p = Math.max(Math.min((scrollTop + inter - switchPos) / bottom, 1.0), 0.0); + const p = Math.max(Math.min((scrollTop + inter - switchPos) / rawWinHeight, 1.0), 0.0); return ((1 - p) * ideal) + (p * inter); } else { return ideal;