From f2649f4eec56ed5525382cb5d04c0ef76b6c915e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 15 Feb 2023 11:57:49 -0500 Subject: [PATCH] better thumb top calculation --- public/src/modules/navigator.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index c1262416a5..f21562813a 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -154,14 +154,10 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct const parent = thumb.parent(); const parentOffset = parent.offset(); - let percent = (index - 1) / ajaxify.data.postcount; - if (index === count) { - percent = 1; - } const thumbIcon = thumb.find('.scroller-thumb-icon'); const thumbIconHeight = thumbIcon.height(); - const newTop = clampTop(thumb, parentOffset.top + ((parent.height() - thumbIconHeight) * percent)); - + const gap = (parent.height() - thumbIconHeight) / (ajaxify.data.postcount - 1); + const newTop = clampTop(thumb, parentOffset.top + ((index - 1) * gap)); const offset = { top: newTop, left: thumb.offset().left }; thumb.offset(offset); updateThumbTextToIndex(thumb, index); @@ -305,6 +301,7 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct touchX = Math.min($(window).width(), Math.max(0, ev.touches[0].clientX)); touchY = Math.min($(window).height(), Math.max(0, ev.touches[0].clientY)); firstMove = true; + thumb.addClass('active'); }); thumb.off('touchmove').on('touchmove', function (ev) { @@ -341,6 +338,7 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct thumb.off('touchend').on('touchend', function () { clearRenderInterval(); if (isNavigating) { + thumb.removeClass('active'); navigator.scrollToIndex(index - 1, true, 0); isNavigating = false; paginationBlockEl.find('.dropdown-menu.show').removeClass('show');