fix: error when trackHeight is 0

This commit is contained in:
Barış Soner Uşaklı
2023-01-09 13:36:52 -05:00
parent 95ded24558
commit 8deb1ba4b4

View File

@@ -98,9 +98,8 @@ function enableHandle() {
function getIndexFromTrack() {
const { top: handleTop } = handleEl.getBoundingClientRect();
const delta = handleTop - trackTop;
const percentage = delta / trackHeight;
const percentage = trackHeight > 0 ? delta / trackHeight : 0;
const index = Math.floor(ajaxify.data.postcount * percentage);
return index;
}