Skip to content

Commit

Permalink
Мелкие улучшения
Browse files Browse the repository at this point in the history
  • Loading branch information
ColCh committed Feb 3, 2014
1 parent e64a8ba commit fe456da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
19 changes: 7 additions & 12 deletions src/abstractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,18 @@
* @param {number} progress
*/
KeyframesCollection.prototype.moveIndexTo = function (progress) {
var leftKeyframe, rightKeyframe;

leftKeyframe = this[ this.cachedIndex ];
rightKeyframe = this[ this.cachedIndex + 1 ];

if (leftKeyframe.numericKey > progress || progress >= rightKeyframe.numericKey) {
if (this[ this.cachedIndex ].numericKey > progress || progress >= this[ this.cachedIndex + 1 ].numericKey) {
do {

if (!rightKeyframe || leftKeyframe.numericKey > progress) {
if (!this[ this.cachedIndex + 1 ] || this[ this.cachedIndex ].numericKey > progress) {
this.cachedIndex--;
}
if (rightKeyframe.numericKey < progress) {
if (this[ this.cachedIndex + 1 ].numericKey < progress) {
this.cachedIndex++;
}
leftKeyframe = this[ this.cachedIndex ];
rightKeyframe = this[ this.cachedIndex + 1 ];
} while (leftKeyframe.numericKey > progress || rightKeyframe.numericKey < progress);

} while (this[ this.cachedIndex ].numericKey > progress || this[ this.cachedIndex + 1 ].numericKey < progress);
}

};
Expand Down Expand Up @@ -302,9 +297,9 @@

if (numericValue.length === 1) {
return numericValue[0] + ( this.propName in toStringValueNoPX ? '' : 'px' );
} else if (numericValue.length === 0) {
} else {
return '';
} // else ?
}

};

Expand Down
3 changes: 2 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@
function blend (from, to, progress, currentValue, roundDigits) {

var valueIsChanged = false;
var i = from.length;

for (var i = 0, m = from.length; i < m; i++) {
while ( i-->0 ) {
valueIsChanged = currentValue[i] !== (currentValue[i] = round( (to[i] - from[i]) * progress + from[i] , roundDigits)) || valueIsChanged;
}

Expand Down

0 comments on commit fe456da

Please sign in to comment.