Skip to content

Commit

Permalink
Fix reduce on empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
pomber committed Mar 16, 2019
1 parent 3019a0f commit 3def52b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export function closestIndex(list, currentIndex) {
}

export function getScrollTop(area, contentHeight, containerHeight, heights) {
const start = heights.slice(0, area.start).reduce((a, b) => a + b);
const start = heights.slice(0, area.start).reduce((a, b) => a + b, 0);
const end =
start + heights.slice(area.start, area.end + 1).reduce((a, b) => a + b);
start + heights.slice(area.start, area.end + 1).reduce((a, b) => a + b, 0);
const middle = (end + start) / 2;
const halfContainer = containerHeight / 2;
const bestTop =
Expand Down

0 comments on commit 3def52b

Please sign in to comment.