diff options
Diffstat (limited to 'lib/utils/progress.js')
-rw-r--r-- | lib/utils/progress.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils/progress.js b/lib/utils/progress.js index b66aea9..9669d86 100644 --- a/lib/utils/progress.js +++ b/lib/utils/progress.js @@ -7,10 +7,18 @@ var calculProgress = function(navigation, current) { var done = true; var chapters = _.chain(navigation) + + // Transform as array .map(function(nav, path) { nav.path = path; return nav; }) + + // Sort entries + .sortBy(function(nav) { + return nav.index; + }) + .map(function(nav, i) { // Calcul percent nav.percent = (i * 100) / Math.max((n - 1), 1); |