Skip to content

Commit

Permalink
Удалены методы item из коллекций. Обновлены тесты.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColCh committed Feb 3, 2014
1 parent 4ff1537 commit 0091af9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
17 changes: 0 additions & 17 deletions src/abstractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,6 @@

};

/**
* Вернёт ключевой кадр по индексу
* @param {number} index
*/
KeyframesCollection.prototype.item = function (index) {
return this[index];
};

/**
* Объект с описанием анимируемого свойства
* @param {string} propertyName
Expand Down Expand Up @@ -374,15 +366,6 @@
return propertyDescriptor;
};

/**
* Вернёт дескриптор свойства по определённому индексу
* @param {number} index
* @return {!PropertyDescriptor}
*/
PropertyDescriptorCollection.prototype.item = function (index) {
return this[ index ];
};

/** @const */
var EasingRegistry = {
/**
Expand Down
20 changes: 10 additions & 10 deletions src/animate_class.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
if (propertyDescriptorIndex === NOT_FOUND) {
propertyDescriptor = this.animatedProperties.add(propertyName);
} else {
propertyDescriptor = this.animatedProperties.item(propertyDescriptorIndex);
propertyDescriptor = this.animatedProperties[ propertyDescriptorIndex ];
}

/** @type {!KeyframesCollection} */
Expand All @@ -95,7 +95,7 @@
var keyframe;

if (keyframeIndex !== NOT_FOUND) {
keyframe = propertyKeyframes.item(keyframeIndex);
keyframe = propertyKeyframes[ keyframeIndex ];
} else {
keyframe = propertyKeyframes.add(progress);
}
Expand All @@ -120,7 +120,7 @@
var propertyDescriptorIndex = this.animatedProperties.indexOf(propertyName);

if (propertyDescriptorIndex !== NOT_FOUND) {
propertyDescriptor = this.animatedProperties.item(propertyDescriptorIndex);
propertyDescriptor = this.animatedProperties[ propertyDescriptorIndex ];

/** @type {!KeyframesCollection} */
var propertyKeyframes = propertyDescriptor.getKeyframes();
Expand All @@ -130,7 +130,7 @@
var keyframe;

if (keyframeIndex !== NOT_FOUND) {
keyframe = propertyKeyframes.item(keyframeIndex);
keyframe = propertyKeyframes[ keyframeIndex ];

return keyframe.getValue();
}
Expand Down Expand Up @@ -159,7 +159,7 @@
if (propertyDescriptorIndex === NOT_FOUND) {
propertyDescriptor = this.animatedProperties.add(propertyName);
} else {
propertyDescriptor = this.animatedProperties.item(propertyDescriptorIndex);
propertyDescriptor = this.animatedProperties[ propertyDescriptorIndex ];
}

/** @type {!Keyframe} */
Expand All @@ -184,7 +184,7 @@
var propertyDescriptorIndex = this.animatedProperties.indexOf(propertyName);

if (propertyDescriptorIndex !== NOT_FOUND) {
propertyDescriptor = this.animatedProperties.item(propertyDescriptorIndex);
propertyDescriptor = this.animatedProperties[ propertyDescriptorIndex ];

/** @type {!Keyframe} */
var startingValue = propertyDescriptor.startingValue;
Expand Down Expand Up @@ -449,7 +449,7 @@

for (var i = 0; i < this.animatedProperties.length; i++) {

propertyDescriptor = this.animatedProperties.item(i);
propertyDescriptor = this.animatedProperties[ i ];
propertyKeyframes = propertyDescriptor.getKeyframes();

propertyKeyframes.moveIndexTo(this.fractionalTime);
Expand Down Expand Up @@ -499,12 +499,12 @@
// Формирование тела правила "@keyframes"
for (var i = 0; i < this.animatedProperties.length; i++) {

var propertyDescriptor = this.animatedProperties.item(i);
var propertyDescriptor = this.animatedProperties[ i ];
var propertyKeyframes = propertyDescriptor.getKeyframes();

for (var j = 0; j < propertyKeyframes.length; j++) {

var propertyKeyframe = propertyKeyframes.item(j);
var propertyKeyframe = propertyKeyframes[ j ];

var key = propertyKeyframe.numericKey * 1e2;
var domStringKey = key_toDOMString(key);
Expand Down Expand Up @@ -626,7 +626,7 @@
} else {
// Возвращение анимированных свойств в доанимированное состояние
for (var i = 0; i < this.animatedProperties.length; i++) {
var propertyDescriptor = this.animatedProperties.item(i);
var propertyDescriptor = this.animatedProperties[ i ];
var startingValue = propertyDescriptor.startingValue;
this.render(propertyDescriptor, startingValue.getValue());
}
Expand Down
8 changes: 5 additions & 3 deletions tests/tests/abstractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ test('KeyframesCollection', function () {
var every = false;
var i = numberOfKeyframes;
while ( i-->1 ) {
every = dummyCollection.item(i).numericKey > dummyCollection.item(i - 1).numericKey;
every = dummyCollection[i].numericKey > dummyCollection[i - 1].numericKey;
if (!every) break;
}

ok(every, 'keyframes are sorted by unique numeric key value');

strictEqual(dummyCollection.item(dummyCollection.indexOf(randomProgress)).numericKey, randomProgress, 'test indexOf with known progress');
strictEqual(dummyCollection[ dummyCollection.indexOf(randomProgress) ].numericKey, randomProgress, 'test indexOf with known progress');
deepEqual(dummyCollection.indexOf(+new Date), -1, 'test indexOf with unknown progress. Must return unknown value');

ok(dummyCollection.item(dummyCollection.indexOfLeft(randomProgress)).numericKey <= randomProgress, 'indexOfLeft must return index of left keyframe (key <= progress)');
dummyCollection.moveIndexTo(randomProgress);

ok(dummyCollection.getLeft().numericKey <= randomProgress, 'indexOfLeft must return index of left keyframe (key <= progress)');

});

Expand Down
4 changes: 2 additions & 2 deletions tests/tests/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ test('toStringValueHooks["color"]', function () {
propertyName = 'color',
vendorizedPropName = 'color';

strictEqual(toStringValueHooks['color'](dummyElement, propertyName, [255, 255, 0], vendorizedPropName), 'rgb(255, 255, 0)', 'rgb color conversion (yellow)');
strictEqual(toStringValueHooks['color'](dummyElement, propertyName, [255, 255, 0, 0.5], vendorizedPropName), 'rgba(255, 255, 0, 0.5)', 'rgb with alpha channel color conversion (yellow, opacity 50%)');
strictEqual(toStringValueHooks['color'](dummyElement, [255, 255, 0]), 'rgb(255, 255, 0)', 'rgb color conversion (yellow)');
strictEqual(toStringValueHooks['color'](dummyElement, [255, 255, 0, 0.5]), 'rgba(255, 255, 0, 0.5)', 'rgb with alpha channel color conversion (yellow, opacity 50%)');
});

// Transform
Expand Down

0 comments on commit 0091af9

Please sign in to comment.