Skip to content

Commit

Permalink
Переместил определение интерполятора в PropertyDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
ColCh committed Jan 19, 2014
1 parent e304d7b commit ea70d94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/abstractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@
this.currentValue = [];
this.keyframes = new KeyframesCollection();
this.startingValue = new Keyframe(null);
if ( COLOR_REG.test(propertyName) ) {
this.blender = blendHooks['color'];
} else if (propertyName in blendHooks) {
this.blender = blendHooks[propertyName];
}
}

/**
Expand All @@ -270,6 +275,12 @@
*/
PropertyDescriptor.prototype.vendorizedPropName = '';

/**
* Функция-интерполятор для данного свойства
* @type {function(!Array.<number>, !Array.<number>, number, !Array.<number>, number): boolean}
*/
PropertyDescriptor.prototype.blender = blend;

/**
* Текущее значение свойства на моменте анимации.
* @type {Array.<number>}
Expand Down
9 changes: 1 addition & 8 deletions src/animate_class.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@
var localEasing, relativeFractionalTime;
var leftKeyframe, rightKeyframe;
var alternativeKeyframe;
var blender = blend;

var isPropertyValueChanged;

Expand Down Expand Up @@ -498,13 +497,7 @@
// Высчет промежуточного значения и перевод его в строку, а затем отрисовка полученного
// Худший случай

if ( COLOR_REG.test(propertyDescriptor.propName) ) {
blender = blendHooks['color'];
} else if (propertyDescriptor.propName in blendHooks) {
blender = blendHooks[propertyDescriptor.propName];
}

isPropertyValueChanged = blender(leftKeyframe.propVal, rightKeyframe.propVal, localEasing, propertyDescriptor.currentValue, BLEND_DIGITS);
isPropertyValueChanged = propertyDescriptor.blender(leftKeyframe.propVal, rightKeyframe.propVal, localEasing, propertyDescriptor.currentValue, BLEND_DIGITS);

if (isPropertyValueChanged) {
this.render(propertyDescriptor.propName, propertyDescriptor.currentValue, propertyDescriptor.vendorizedPropName);
Expand Down

0 comments on commit ea70d94

Please sign in to comment.