Skip to content

Commit

Permalink
MOD: move getContentHeight to variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-nginx authored Sep 12, 2017
1 parent 742d1ca commit 028fe60
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions source/js/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ NexT.utils = NexT.$u = {
$top.toggleClass('back-to-top-on', window.pageYOffset > THRESHOLD);

var scrollTop = $(window).scrollTop();
var docHeight = $('#content').height();
var winHeight = $(window).height();
var contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight);
var scrollPercent = (scrollTop) / (contentMath);
var contentHeight = NexT.utils.getContentHeight();
var scrollPercent = (scrollTop) / (contentHeight);
var scrollPercentRounded = Math.round(scrollPercent*100);
var scrollPercentMaxed = (scrollPercentRounded > 100) ? 100 : scrollPercentRounded;
$('#scrollpercent>span').html(scrollPercentMaxed);
Expand Down Expand Up @@ -265,6 +263,14 @@ NexT.utils = NexT.$u = {
return scrollbarWidth;
},

getContentHeight: function () {
var docHeight = $('#content').height(),
winHeight = $(window).height(),
contentHeight = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight);

return contentHeight;
},

/**
* Affix behaviour for Sidebar.
*
Expand Down

0 comments on commit 028fe60

Please sign in to comment.