Fix scrollmap included NaN values.

This commit is contained in:
Guo Xiang Tan 2017-11-23 18:01:53 +08:00
parent 9f0798682e
commit ab839d134b

@ -231,21 +231,21 @@ export default Ember.Component.extend({
let position = 0; let position = 0;
_.times(numberOfLines, currentLineNumber => { for (let i = 1; i < numberOfLines; i++) {
if (scrollMap[currentLineNumber] !== -1) { if (scrollMap[i] !== -1) {
position++; position++;
return; continue;
} }
let top = nonEmptyList[position]; let top = nonEmptyList[position];
let bottom = nonEmptyList[position + 1]; let bottom = nonEmptyList[position + 1];
scrollMap[currentLineNumber] = scrollMap[i] =
(( ((
scrollMap[bottom] * (currentLineNumber - top) + scrollMap[bottom] * (i - top) +
scrollMap[top] * (bottom - currentLineNumber) scrollMap[top] * (bottom - i)
) / (bottom - top)).toFixed(2); ) / (bottom - top)).toFixed(2);
}); };
return scrollMap; return scrollMap;
}, },