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
1 changed files with 7 additions and 7 deletions

View File

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