Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Fixed Offset Animation Bug
Browse files Browse the repository at this point in the history
Fix for offset problem: offset make wrong values when duplicated
keyframe found. Now if duplicate keyframe number is in different
keyframe index -> use loop index value to apply it current index
instead duplicate keyframe index.
  • Loading branch information
Creatide committed Mar 23, 2016
1 parent fc179e1 commit e6a91f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions AnimateMate.sketchplugin/Contents/Sketch/library/Animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ Animate.prototype.offsetAnimation = function (offsetType, stepSize, responseValu
switch (offsetType) {
case 'normal':
var offsetValuesObj = offsetValues(refKeyframe, responseValues, 0);
tmpLayer[i].setKeyframeValues(keyframeNumber, offsetValuesObj, true);
tmpLayer[i].setKeyframeValues(keyframeNumber, offsetValuesObj, true, j);
break;
case 'stepped (layer)':
var offsetValuesObj = offsetValues(refKeyframe, responseValues, j * stepSize);
tmpLayer[i].setKeyframeValues(keyframeNumber, offsetValuesObj, true);
tmpLayer[i].setKeyframeValues(keyframeNumber, offsetValuesObj, true, j);
break;
case 'stepped (selection)':
var offsetValuesObj = offsetValues(refKeyframe, responseValues, i * stepSize);
tmpLayer[i].setKeyframeValues(keyframeNumber, offsetValuesObj, true);
tmpLayer[i].setKeyframeValues(keyframeNumber, offsetValuesObj, true, j);
break;
}
}
Expand Down
10 changes: 9 additions & 1 deletion AnimateMate.sketchplugin/Contents/Sketch/library/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,22 @@ Animation.prototype.updateLayerName = function (newBaseName, newEasingType, over
};


Animation.prototype.setKeyframeValues = function (keyframeNumber, valuesObject, changeKeyframeNumber) {
Animation.prototype.setKeyframeValues = function (keyframeNumber, valuesObject, changeKeyframeNumber, loopIndex) {

var refKeyframe = null;
var loopIndex = loopIndex || null;
var valuesObject = valuesObject || this.getOriginalValues();
var duplicates = this.searchDuplicateKeyframes(keyframeNumber);

if (!isNaN(duplicates)) {

refKeyframe = this.keyframes[duplicates];

// Offset animation skip duplicates if not in current loop index
if (loopIndex && loopIndex != duplicates) {
refKeyframe = this.keyframes[loopIndex];
}

} else {
this.keyframes[this.keyframesLength] = {};
refKeyframe = this.keyframes[this.keyframesLength];
Expand Down

0 comments on commit e6a91f2

Please sign in to comment.