MCPcopy Index your code
hub / github.com/web-animations/web-animations-js / convertToArrayForm

Function convertToArrayForm

src/normalize-keyframes.js:176–218  ·  view source on GitHub ↗
(effectInput)

Source from the content-addressed store, hash-verified

174 };
175
176 function convertToArrayForm(effectInput) {
177 var normalizedEffectInput = [];
178
179 for (var property in effectInput) {
180 if (property in ['easing', 'offset', 'composite']) {
181 continue;
182 }
183
184 var values = effectInput[property];
185 if (!Array.isArray(values)) {
186 values = [values];
187 }
188
189 var keyframe;
190 var numKeyframes = values.length;
191 for (var i = 0; i < numKeyframes; i++) {
192 keyframe = {};
193
194 if ('offset' in effectInput) {
195 keyframe.offset = effectInput.offset;
196 } else if (numKeyframes == 1) {
197 keyframe.offset = 1.0;
198 } else {
199 keyframe.offset = i / (numKeyframes - 1.0);
200 }
201
202 if ('easing' in effectInput) {
203 keyframe.easing = effectInput.easing;
204 }
205
206 if ('composite' in effectInput) {
207 keyframe.composite = effectInput.composite;
208 }
209
210 keyframe[property] = values[i];
211
212 normalizedEffectInput.push(keyframe);
213 }
214 }
215
216 normalizedEffectInput.sort(function(a, b) { return a.offset - b.offset; });
217 return normalizedEffectInput;
218 };
219
220 function normalizeKeyframes(effectInput) {
221 if (effectInput == null) {

Callers 1

normalizeKeyframesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…