Skip to content

Commit 52c0c85

Browse files
committed
Fixed eased range grid stagger
1 parent 2b713b0 commit 52c0c85

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

src/tweens/builders/StaggerBuilder.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ var StaggerBuilder = function (value, options)
9595
gridValues[toY][toX] = dist;
9696
}
9797
}
98-
99-
console.table(gridValues);
100-
console.log('gridMax', gridMax);
10198
}
10299

103100
var easeFunction = (ease) ? GetEaseFunction(ease) : null;
@@ -111,10 +108,11 @@ var StaggerBuilder = function (value, options)
111108

112109
if (grid)
113110
{
114-
result = function (target, key, value, index, total)
111+
// result = function (target, key, value, index, total)
112+
result = function (target, key, value, index)
115113
{
116114
// zero offset
117-
total--;
115+
// total--;
118116

119117
var gridSpace = 0;
120118
var toX = index % gridWidth;
@@ -129,23 +127,15 @@ var StaggerBuilder = function (value, options)
129127

130128
if (isRange)
131129
{
132-
var spacing;
133-
134-
if (fromCenter)
135-
{
136-
spacing = ((value2 - value1) / total) * (index * 2);
137-
}
138-
else
139-
{
140-
spacing = ((value2 - value1) / total) * index;
141-
}
130+
var diff = (value2 - value1);
142131

143132
if (easeFunction)
144133
{
134+
output = ((gridSpace / gridMax) * diff) * easeFunction(gridSpace / gridMax);
145135
}
146136
else
147137
{
148-
output = gridSpace * value1;
138+
output = (gridSpace / gridMax) * diff;
149139
}
150140
}
151141
else if (easeFunction)
@@ -157,7 +147,7 @@ var StaggerBuilder = function (value, options)
157147
output = gridSpace * value1;
158148
}
159149

160-
console.log('>', index, '/', total, 'from', fromX, fromY, 'to', toX, toY, 'gridSpace:', gridSpace, 'RESULT:', (output + start));
150+
// console.log('>', index, '/', total, 'from', fromX, fromY, 'to', toX, toY, 'gridSpace:', gridSpace, 'start', start, 'RESULT:', (output + start));
161151

162152
return output + start;
163153
};
@@ -221,7 +211,7 @@ var StaggerBuilder = function (value, options)
221211
output = fromIndex * value1;
222212
}
223213

224-
console.log('>', index, '/', total, 'fromIndex:', fromIndex, 'spacing:', spacing, 'RESULT:', output);
214+
// console.log('>', index, '/', total, 'fromIndex:', fromIndex, 'spacing:', spacing, 'RESULT:', output);
225215

226216
return output + start;
227217
};

0 commit comments

Comments
 (0)