Skip to content

Commit

Permalink
FIX: invalid math of scroll percent. #1615
Browse files Browse the repository at this point in the history
Invalid math of scroll percent when sidebar is bigger than content.
  • Loading branch information
ivan-nginx committed Apr 23, 2017
1 parent 340c984 commit 3bfb633
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/js/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ NexT.utils = NexT.$u = {
var scrollTop = $(window).scrollTop();
var docHeight = $('#content').height();
var winHeight = $(window).height();
var scrollPercent = (scrollTop) / (docHeight - winHeight);
var contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight);
var scrollPercent = (scrollTop) / (contentMath);
var scrollPercentRounded = Math.round(scrollPercent*100);
var scrollPercentMaxed = (scrollPercentRounded > 100) ? 100 : scrollPercentRounded;
$('#scrollpercent>span').html(scrollPercentMaxed);
Expand Down

0 comments on commit 3bfb633

Please sign in to comment.