Permalink
Browse files

Fix hotnumber when adjusting 0.

  • Loading branch information...
jeresig committed Mar 9, 2012
1 parent 5cccd59 commit 9a56b96b8f58453504d9d471da7a50eac570616a
Showing with 4 additions and 3 deletions.
  1. +4 −3 js/utils.js
View
@@ -776,10 +776,11 @@ var isEqual = function( a, b, msg ) {
}
// Compute the offset, relative to the center position
- var curNum = newNum < 50 ? (50 - newNum) + 50 : newNum,
- offset = ((Math.log( firstNum * 500 ) - Math.log( firstNum * ((100 - curNum) * 10) )) * firstNum);
+ var offsetNum = firstNum === 0 ? newNum === 50 ? 0 : 1 : firstNum;
+ curNum = newNum < 50 ? (50 - newNum) + 50 : newNum,
+ offset = ((Math.log( offsetNum * 500 ) - Math.log( offsetNum * ((100 - curNum) * 10) )) * offsetNum);
- newNum = firstNum + ((newNum < 50 ? -1 : 1) * (!isFinite( offset ) ? firstNum * 4 : offset));
+ newNum = firstNum + ((newNum < 50 ? -1 : 1) * (!isFinite( offset ) ? offsetNum * 4 : offset));
newNum = newNum.toFixed( decimal );
// Figure out the position of the old number to replace

0 comments on commit 9a56b96

Please sign in to comment.