Skip to content

Commit

Permalink
Decrease code complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
jcopperfield committed Dec 3, 2017
1 parent 38574c3 commit f7d4d54
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/core/core.element.js
Expand Up @@ -35,12 +35,10 @@ function interpolate(start, view, model, ease) {
if (type === typeof origin) {
if (type === 'string') {
c0 = color(origin);
if (c0.valid) {
c1 = color(target);
if (c1.valid) {
view[key] = c1.mix(c0, ease).rgbString();
continue;
}
c1 = color(target);
if (c0.valid && c1.valid) {
view[key] = c1.mix(c0, ease).rgbString();
continue;
}
} else if (type === 'number' && isFinite(origin) && isFinite(target)) {
view[key] = origin + (target - origin) * ease;
Expand Down Expand Up @@ -80,11 +78,9 @@ helpers.extend(Element.prototype, {

// No animation -> No Transition
if (!model || ease === 1) {
if (setAnimating) {
me.animating = false;
}
me._view = model;
me._start = null;
delete me.animating;
return me;
}

Expand All @@ -96,12 +92,12 @@ helpers.extend(Element.prototype, {
start = me._start = {};
}

interpolate(start, view, model, ease);

if (setAnimating && !me.animating) {
me.animating = true;
}

interpolate(start, view, model, ease);

return me;
},

Expand Down

0 comments on commit f7d4d54

Please sign in to comment.